From: Robert Klemme Date: 2006-08-17T05:50:05+09:00 Subject: Re: Reading in files, keeping *ALL* info from file Chris Binc wrote: > Hi, > > I am trying to read in a file and parse it. It uses hex values, such > as 0x0000 to identify certain tags. When I read this into > Ruby(IO.read), it simply gives me a blank string: "" However, I need to > be able to get 0x0000 from my input. The same is true of 0x0001, which > returns the same as 0x1, but I need the leading 0's. > > I have attempted to use the lower lever sysread an syswrite, but to no > avail. I have the same problem and in addition, when asked to read > 0x0000 it returns an (IOError) where read simply returns "". > > Is there any way for me to read this information in and keep every byte? Since you're reading binary data, here's what I'd do bytes = File.open(f, "rb") {|io| io.read} Kind regards robert