From: "Iñaki Baz Castillo" Date: 2009-12-03T19:01:21+09:00 Subject: Re: Encoding/decoding a image as Base64 (fails under Ruby1.9 but works under Ruby1.8) El Jueves, 3 de Diciembre de 2009, Lars Christensen escribió: > 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" Yes. It seems that usng "to_s" could be a bit problematic under Ruby1.9 due to the new behaviour... Thanks. -- Iñaki Baz Castillo