[plt-scheme] Parsing Binary Files
Hi Danny, Matt,
Thanks very much for your responses - as you probably guessed, I had a
mistake.
Cheers,
David
On Tue, Mar 07, 2006 at 10:18:16AM -0800, Danny Yoo wrote:
>
>
> On Tue, 7 Mar 2006, David J. Neu wrote:
>
> > I'm parsing a binary file, and calls to read-byte and read-bytes return
> > #<eof> when that byte is encountered.
>
> Hi David,
>
> Could it be that the file is opened in text mode? I'm trying to duplicate
> this problem now, and I can't:
>
> ;;;;;;
> > (define b (bytes 0 1 0 1))
> > (define p (open-input-bytes b))
> > (read-byte p)
> 0
> > (read-byte p)
> 1
> > (read-byte p)
> 0
> > (read-byte p)
> 1
> > (read-byte p)
> #<eof>
> ;;;;;;
>
> which looks perfectly ok to me: the port is perfectly happy to emit 0 as a
> byte value.
>
>
> > The input-port being read from was opened using open-input-bytes.
>
> Wait, but open-input-bytes already takes in a source of bytes: it doesn't
> take in a port itself. You mentioned earlier that you're parsing a binary
> file. So I'm confused about the domains here. How are you getting from
> the binary file to bytes?
>
> I hate guessing. *grin* Can you show us an example of what you mean?
>
>
> Good luck to you!
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme