From: Mike Shock Date: 2007-02-10T03:41:01+09:00 Subject: Re: Help with Readlines error Hi! There is nothing wrong: you are reading the data in Unicode, namely in UCS2 - fixed 2-byte representation of string characters. Here's my test program: = = = data = File.open('unicode.txt').readlines p data puts data = = = and its output: ["\377\376T\000h\000i\000s\000 \000i\000s\000 \000a\000 \000l\000i\000n\000e\000 \000i\000n\000 \000U\000n\000i\000c\000o\000d\000e\000 \000(\000U\000S\000C\0002\000)\000.\000"] This is a line in Unicode (USC2). Regards - Mike Shock Bucco wrote: > I don't know if it is me or if something is wrong with Ruby. I am > using ruby 1.8.5 (2006-08-25) [i386-mswin32] on an XP box. I am > following alon with some examples for readline in my new "Everyday > Scripting with Ruby" book. The book has me in irb and is explaining > File.open('somefile.txt').readlines. I am not getting the same > output. My output has each word as a member of the array, but each > character of each word has a \000 in front of the character. for > example: > > irb(main):002:0> new_inventory = File.open('new- > inventory.txt').readlines > => ["\377\376e\000x\000e\000r\000c\000i\000s\000e\000-\000d\000i\000f > \000f\000e\ > ... > r\000\n", "\000"] > > Any ideas what is wrong? > > Thanks:) > > SA > > >