From: "Eric I." Date: 2008-06-05T06:19:38+09:00 Subject: Re: Beginner: Read file On Jun 4, 2:25 pm, David Masover wrote: > On Wednesday 04 June 2008 12:31:58 Michael Linfield wrote: > > > File.open("myfile") do |file| > > file.each_byte {|x| puts x} > > end > > > The value of 'x' will be in ascii, I'll let you figure out how to > > translate ascii back into text :) > > I believe that's why each_byte is depricated -- each_char will read each > character, even when a character is more than a byte. Well, unless I'm mistaken.... Ruby 1.8.6 has IO#each_byte but not IO#each_char. Ruby 1.8.7 and 1.9 have both IO#each_byte and IO#each_char, but neither deprecates IO#each_byte since it's still useful for processing byte-oriented (i.e., binary) files/streams. Eric ==== LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE workshops. Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich. Ready for Rails Ruby Wkshp June 23-24 Ann Arbor, Mich. Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich. Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich Please visit http://LearnRuby.com for all the details.