Archived Forum Post

Index of archived forum posts


FTP Downloads with Japanese Filenames in Ruby?

Apr 21 '14 at 12:31

I seem to be having a problem with downloading Japanese file names. These are supposed to be UTF-8 but I have also tried [Shift_JIS EUC-JP EUC-CN] with the same result (put_DirListingCharset).

From the lastErrorXml it looks like the Japenese part of the file is gone?


The DirListingCharset property tells Chilkat how to interpret the bytes of a directory listing.

What you want instead is to set the CommandCharset property -- to tell the FTP server how to interpret the bytes in the commands sent over the control connection.

In addition, you'll need to ensure that for the string passed to a Chilkat method, that the bytes are correctly interpreted. If the Ruby string is utf-8, make sure to set the "Utf8" property of the Chilkat FTP2 object. For example:


Remember: In Ruby, a String object holds and manipulates an arbitrary sequence of bytes, typically representing characters. Chilkat however, must know how to interpret the bytes, and therefore needs to know if you are passing bytes representing characters using the ANSI encoding (whatever that may be for the local machine, which may be Shift-JIS for Japanese computers), or utf-8.

In summary:

Step 1 is to make sure the string is passed to Chilkat so that Chilkat correctly interprets the bytes.

Step 2 is to make sure the string is passed to the FTP server using the character encoding expected by the FTP server, so that it can correctly interpret the bytes. This is done by setting the CommandCharset property.