From: Luther Date: 2009-02-17T10:33:39+09:00 Subject: Re: invalid byte sequence in US-ASCII (ArgumentError) On Mon, 2009-02-16 at 14:20 +0900, Tom Link wrote: > > but now I know my program will puke > > on any text file with multibyte characters. > > Not necessarily. > > Here is a useful summary of encodings in 1.9: > http://blog.nuclearsquid.com/writings/ruby-1-9-encodings > > Basically, you have script encoding, internal encoding, and external > encoding. In you case, you should probably read the files as ASCII8BIT > or binary, I guess. > Thank you. I've put 'r:binary' in the line where I open the file, and now it seems to work fine. Although if I didn't want to be lazy, I would probably read it with the default encoding, catch the ArgumentError, then reread the file. Thanks again... Luther