I have a list of files with utf-8 characters in the name. Net::FTP
them well, the content is just as I expected. But the problem comes with
the filename I expect on the server side. When I expect it to be
“somefile__.sample” it will upload as “somefile_©_.sample”.
I made some example code so you can duplicate it:
https://gist.github.com/3949372. The catch is that you need an FTP
to try it (line 51, 52). This will create a file with an special utf8
in /tmp and attempt to upload it.
I followed with debugger through the logic on Net::Ftp.put and found out
that the @socket.write method is responsible for this (@socket is a
TCPSocket object). So I’ve tried overloading the methods putfile and
storbinary from Net::FTP, setting @sock.set_encoding(‘utf-8’) to set the
default_external encoding, but to no avail. My filenames still appear
the wrong encoding on the FTP server.
- I’m using ruby-1.9.3-p194
- I’ve tried in clients such as Mac’s transmit and it works as expected,
the special chars are respected.