From: mike@... (Mike Stok) Date: 2003-09-20T04:19:38+09:00 Subject: Re: Trouble with binary files? In article <20030919190050.36969.qmail@web14006.mail.yahoo.com>, wrote: >I'm trying to write a program that will read a binary >file into an buffer, do stuff with it, and then write >the result back into another file. However, I'm >running into a problem. > >I haven't been able to find a way that will read in >more than the first 160 bytes (of a 910 byte file). >I've tried using each_byte and looping with getc, as >well as storing the results in a string or an array. > >I've never had this sort of problem working with text >files. Is there something else I have to do to be able If you're on a windows platform this can happen if you have a ^Z in your file. If this is your problem then binmode may help: [mike@ratdog mike]$ ri binmode This is a test 'ri'. Please report errors and omissions on http://www.rubygarden.org/ruby?RIOnePointEight ------------------------------------------------------------- IO#binmode ios.binmode -> ios ------------------------------------------------------------------------ Puts ios into binary mode. This is useful only in MS-DOS/Windows environments. Once a stream is in binary mode, it cannot be reset to nonbinary mode. Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA