Hey there,
I have a list of files with utf-8 characters in the name. Net::FTP
handles
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:
Net::FTP and UTF-8 · GitHub. The catch is that you need an FTP
account
to try it (line 51, 52). This will create a file with an special utf8
char
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
with
the wrong encoding on the FTP server.
Any suggestions?
PS.
- 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.