Alex Young wrote in post #1022945:
> This surprised me:

Nothing surprises me any more about encodings in ruby 1.9.

FWIW, there's a similar case with String.new. Whereas a string literal 
gets its encoding from the source encoding of the file, String.new 
doesn't.

brian@x100:~$ ruby192 -e 'p "".encoding'
#<Encoding:UTF-8>
brian@x100:~$ ruby192 -e 'p String.new.encoding'
#<Encoding:ASCII-8BIT>
brian@x100:~$ echo 'p "".encoding' | ruby192
#<Encoding:UTF-8>
brian@x100:~$ echo 'p String.new.encoding' | ruby192
#<Encoding:ASCII-8BIT>
brian@x100:~$ echo 'p "".encoding' > x.rb && ruby192 x.rb
#<Encoding:US-ASCII>
brian@x100:~$ echo 'p String.new.encoding' > x.rb && ruby192 x.rb
#<Encoding:ASCII-8BIT>

However, String.new doesn't seem to be getting its encoding from the 
environment, which your program suggests StringIO.new does.

All of this is completely undocumented, and therefore whatever behaviour 
you get is what you get. Fine if you like stamp collecting though.

Regards,

Brian.

-- 
Posted via http://www.ruby-forum.com/.