From: Angelo NN Date: 2011-04-07T05:15:51+09:00 Subject: Re: Windows 2008 Server: Reading Text File with Ruby. Jonathan Hudson wrote in post #991297: > On Thu, 7 Apr 2011 04:58:54 +0900, Angelo NN wrote: > >> > or perhaps >> >> >> contents = File.open('tmp', 'r:utf-16') { |f| f.read } >> (irb):15: warning: Unsupported encoding utf-16 ignored >> => >> "\xFF\xFE\n\x00\n\x00\n\x00\n\x00C\x00a\x00p\x00a\x00c\x00i\x00t\x00y\x00=\x0 >> 08\x005\x008\x009\x009\x003\x004\x005\x009\x002\x00\n\x00\n\x00\n\x00\n\x00\n\x0 >> 0\n\x00" >> > > I think the old ways still work: > > require 'iconv' > content=File.binread('tmp') > # TO FROM (set TO to 'native encoding') > text = Iconv::conv("utf-8",'utf-16', content) > puts text > > -jh Wow - Awesome. That worked. Thanks Jonathan! -- Posted via http://www.ruby-forum.com/.