From: "F. Senault" Date: 2011-04-07T05:45:33+09:00 Subject: Re: Windows 2008 Server: Reading Text File with Ruby. Le 6 avril 2011 � 21:58, Angelo NN a �crit : > Thanks - I tried utf-16. Unfortunately it gives a "Unsupported encoding > utf-16 ignored" message. Maybe it's time to switch to another Operating > System for me :) If you want the list of encodings that ruby supports, try : ruby -e 'puts Encoding.list' I think you are looking for 'UTF16-LE'. >>> 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" >> contents = File.open('tst', 'rb:utf-16le') { |f| f.read } => "\uFEFF\n\nNode,Capacity\n\nPS,8589934592" If you want to ignore the BOM (byte order mark), just skip the two first bytes : >> contents = File.open('tst', 'rb:utf-16le') { |f| f.seek(2) ; f.read } => "\n\nNode,Capacity\n\nPS,8589934592" HTH, Fred -- Cause we are the ones that wanna play Always wanna go But you never wanna stay And we are the ones that want to chose Always wanna play But you never wanna to lose (System of a Down, Aerials)