FTP Unicode Directory Listings
Question:
Files on the FTP server contain Unicode characters (Chinese, Japanese, Russian, etc.). How do I get the correct filenames in my (Chilkat FTP2) client?
Answer:
It is very dependent on the capabilities of the FTP server. Many servers are incapable of sending Unicode directory listings.
If an FTP server supports Unicode directory listings, it will use utf-8 (which is the multibyte encoding for Unicode). An FTP server indicates UTF8 support in the response to the FEAT command:
C> FEAT
S> 211-Extensions supported
S> SIZE
S> MDTM
S> MLST size*;type*;perm*;create*;modify*;
S> LANG EN*
S> REST STREAM
S> UTF8
S> 211 end
Note: Many FTP servers don’t even support the FEAT command.
The Chilkat FTP2 component automatically sends a FEAT command after connecting. One reason for doing this is to auto-detect UTF8 support. If present, Chilkat FTP2 will automatically receive directory listings in the utf-8 encoding. (For programming languages that use Unicode strings, Chilkat will automatically convert utf-8 to a proper Unicode string in your programming language, such as C#, VB.NET, ASP, VB6, Delphi, etc.)
The FTP2 component’s AutoFeat property (true/false) controls whether the FEAT command is automatically sent. It defaults to true.
The DirListingCharset property can be set to override the auto-detection. You would only use DirListingCharset if the FTP server sends ANSI directory listings where the ANSI charset on the server is different from the ANSI charset on the client. For example, perhaps the FTP server is in Japan where the ANSI charset is Shift-JIS, but your FTP client is in France where the ANSI charset is iso-8859-1 (or Windows-1252). The DirListingCharset might also be used if the FTP server sends utf-8 listings but does not support the FEAT command, or does not list UTF8 in the FEAT response.
To see the FEAT response of your FTP server, examine the contents of the FTP2’s SessionLog property after connecting. (Be sure to enable session logging by setting the KeepSessionLog property = true prior to connecting.)