From: nobu.nokada@... Date: 2002-06-02T03:29:52+09:00 Subject: Re: Reading binary files (or strings) Hi, At Sat, 1 Jun 2002 22:46:30 +0900, Han Holl wrote: > >>or: > >> iostream.unpack(format) ## not found either. > >> > > > >You can use StringIO. > >:pserver:anonymous@cvs.ruby-lang.org:/src/rough/ext/stringio/ > > > >or included in 1.7 > > > I found that a bit hard to figure out. The comments in stringio.rb > seem to be > all Japanese, and stringio.c in 1.7 isn't commented (or documented) at all Sorry, I've written nothing other than TestStringIO.rb in rough/ext/stringio. Since it doesn't have #unpack: require 'stringio' class Dotqread def initialize(fn) @blob = StringIO.new(File.open(fn) {|f| f.read}) end def wordread @blob.read(2).unpack("s")[0] end def longread @blob.read(4).unpack("L")[0] end def txtread Opstring.new(@blob.read(wordread)) end end -- Nobu Nakada