Reading/Writing Binary Data in Haskell

Glynn Clements glynn.clements@virgin.net
Wed, 9 Jul 2003 14:16:09 +0100


Wolfgang Jeltsch wrote:

> > However, a simple and fairly generic mechanism for doing this is:
> >
> > 1. Read in a list of "Char"s with the standard I/O functions.
> 
> This will most likely cause problems under Windows. The reason is that the 
> standard I/O functions are intended for reading and writing text, and that's 
> why under Windows the sequence CRLF (#0D#0A) is interpreted as a single LF 
> (#0A) and EOF (#1A) is interpreted as the end of the file.

Good point.

Both GHC and Hugs provide openFileEx, which allows files to be read in
binary mode (without EOL/EOF translations).

-- 
Glynn Clements <glynn.clements@virgin.net>