From: Jonathan Hudson Date: 2011-04-07T04:47:45+09:00 Subject: Re: Windows 2008 Server: Reading Text File with Ruby. On Thu, 7 Apr 2011 04:35:44 +0900, Angelo NN wrote: > Jonathan Hudson wrote in post #991289: > > On Thu, 7 Apr 2011 04:30:13 +0900, Angelo NN wrote: > > > >> the output: > >> Thank you for your help. > >> 02\x00" > >> irb(main):004:0> > >> > >> -- > >> Posted via http://www.ruby-forum.com/. > >> > >> > > > > As it starts with a UTF-16 LE Byte order marker, that's a pretty good > > clue as to the encoding. > > > > -jh > > Thank you. > > Can you suggest where I can read/etc. about how to change the encoding > for the imported file? I'm not at all familiar with dealing with encodings on Windows, but assuming you're using a 1.9x ruby, contents = File.open('tmp', 'r:utf-16') { |f| f.read } or perhaps contents = File.open('tmp', 'r:utf-16le') { |f| f.read } Given the BOM, I'd hope that the former might work. -jh