Archived Forum Post

Index of archived forum posts

Question:

Wide Characters Stripped from FTP Filenames in Ruby (but not Java)

Dec 24 '14 at 08:57

I have a Ruby test and a Java test that simply connects to a test server and displays the output of a directory (dirTreeXml). Both are using the latest versions of chilkat and the Ruby version is 2.1.5 (tested w/ 2.1.1, same result).

The Java version works as expected, however some wide characters are stripped off the file names when testing with Ruby. You can test/replicate using the sent scripts, the connection will work.


Answer

I have a feeling that this is just a matter of telling the CkFtp2 object that you want strings to be utf-8 when passed to the Chilkat API and returned from the Chilkat API. This is different than the FTP2's DirListingCharset and CommandCharset properties, which control the charset used in communications between Chilkat and the FTP server. I'm talking about the strings passing between the app and Chilkat. In Java, it can only be utf-8 -- there is no other choice because in Java strings are effectively objects (and utf-8 when emitting to stdout). In Ruby however, strings are really just a null-terminated sequence of bytes. The default is to assume ANSI -- and it's because of this that your chars get dropped (because there is no single-byte ANSI representation for those chars). You want to tell the CkFtp2 that it should treat strings passed in as utf-8, and return utf-8 strings, and this is via the Utf8 property:

ftp2_object.put_Utf8(true)