From: Lars Christensen Date: 2009-12-03T17:04:01+09:00 Subject: Re: Encoding/decoding a image as Base64 (fails under Ruby1.9 but works under Ruby1.8) On Thu, Dec 3, 2009 at 1:22 AM, Iņaki Baz Castillo wrote: >  File.open("base64.txt","w") do |file| >    file.write [open("icon.png").read].pack("m") >  end > >  File.open('new_icon.png', 'wb') do |file| >    file << (IO.readlines('base64.txt').to_s.unpack('m')).first >  end > > Which is the difference when using Ruby1.9? how to solve it? > Thanks a lot. In Ruby 1.9, Array#to_s is an alias for Array#inspect. In Ruby 1.8, Array#to_s worked like Array#join with no arguments. Try this: IO.read "base64.txt"