From: "pablasso@..." Date: 2012-10-26T01:01:36+09:00 Subject: Net::FTP and UTF-8 encoding --20cf307abca733ff2304cce4511c Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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_=A9_.sample" it will upload as "somefile_=C2=A9_.sample". I made some example code so you can duplicate it: https://gist.github.com/3949372. 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. --20cf307abca733ff2304cce4511c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hey there,

I have a list of files with= utf-8 characters in the name. Net::FTP handles them well, the content is j= ust as I expected. But the problem comes with the filename I expect on the = server side. When I expect it to be "somefile_=A9_.sample" it wil= l upload as "somefile_=C2=A9_.sample".

I made some example code so you can duplicate it:=A0https://gist.github.com/3949372.=A0The catch is th= at 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 th= at 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 defau= lt_external encoding, but to no avail. My filenames still appear with the w= rong encoding on the FTP server.

Any suggestions?

PS.=A0
- I'm using=A0ruby-1.= 9.3-p194
- I've tried in clients such as Mac's transmit and it works as expe= cted, the special chars are respected.
--20cf307abca733ff2304cce4511c--