title: Ruby Net::FTP - Downloading files from a server
body: <p>I am trying to download certain files from a remote server using Ruby's Net::FTP class here is my code</p>
  
  <pre><code>require 'net/ftp'
  ftp = Net::FTP.new
  ftp.connect('mydomain', '21')
  ftp.login('username', 'password')
  ftp.passive = true
  
    ftp.chdir("testing")
  
    ftp.getbinaryfile('個人情報.csv', 'test1.csv')
    puts "#{Time.now} &gt; Downloaded 個人情報.csv."
  
    ftp.getbinaryfile('住所.csv', 'test2.csv')
    puts "#{Time.now} &gt; Downloaded 住所.csv"
  
  ftp.close
  </code></pre>
  
  <p>I am getting the following errors</p>
  
  <pre><code>$ ruby ftp_download.rb
  
  /usr/local/lib/ruby/2.3.0/net/ftp.rb:340:in `getresp': 451 No mapping for the Unicode character exists in the target multi-byte code page.  (Net::FTPTempError)
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:367:in `block in sendcmd'
      from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:365:in `sendcmd'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:424:in `transfercmd'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:501:in `block (2 levels) in retrbinary'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:214:in `with_binary'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:499:in `block in retrbinary'
      from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:498:in `retrbinary'
      from /usr/local/lib/ruby/2.3.0/net/ftp.rb:632:in `getbinaryfile'
      from ftp_download.rb:26:in `&lt;main&gt;'
  </code></pre>
  
  <p>The tagrget files are <a href="https://en.wikipedia.org/wiki/Shift_JIS" rel="nofollow">SJIS</a> encoded. <br />
  What am i doing wrong ? any help much appreciated! Thank you</p>