Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.6k views
in .NET FTP by (160 points)
When I set the Command encoding to UTF, the system fails to login to a Filezilla FTP server.


220-FileZilla Server version 0.9.32 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
...USER rss
500 Syntax error, command unrecognized.

The specific characters in issue appear to bt the UTF8 BOM
http://en.wikipedia.org/wiki/Byte-order_mark

00000000 ef bb bf ...
00000003 55 53 45 52 20 72 73 73 0d 0a USER rss ..


I hacked the connection method since I was having trouble figuring out what was causing the BOM to be sent..


/// <summary>
/// Supply the user-name to log into an account on the FTP server. 
/// Must be followed by the <see cref="Password(string)"/> method.
/// Note that <see cref="Connect()"/> must be called first. 
/// </summary>
/// <param name="user">User-name.</param>
public virtual void User(string user)
{            
            CheckConnection(true);

   // Ian Darke - hack for unicode auths!
   control.SendCommand("");

            FTPReply reply = control.SendCommand("USER " + user);
            
            // we allow for a site with no password - 230 response
            lastValidReply = control.ValidateReply(reply, "230", "331");
}

2 Answers

0 votes
by (162k points)
What you can do is create a UTF8 encoding that doesn't use a BOM, e.g.

UTF8Encoding utf8 = new UTF8Encoding(false);
0 votes
by (160 points)
Thanks.. that did the trick.

Categories

...