[Haskell-cafe] Writing binary files?
Ron de Bruijn
rondebruijn at yahoo.com
Sat Sep 11 16:32:00 EDT 2004
--- Sven Panne <Sven.Panne at aedion.de> wrote:
> Hal Daume III wrote:
> > There's a Binary module that comes with GHC that
> you can get somewhere (I
> > believe Simon M wrote it). I have hacked it up a
> bit and added support
> > for bit-based writing, to bring it more in line
> with the NHC module.
> > Mine, with various information, etc., is available
> > http://www.isi.edu/~hdaume/haskell/NewBinary/
> Hmmm, I'm not sure if that is what Ron asked for.
> What I guess is needed is
> support for things like:
> "read the next 4 bytes as a low-endian unsigned
> "read the next 8 bytes as a big-endian IEEE 754
> "write the Int16 as a low-endian signed integer"
> "write the (StorableArray Int Int32) as
> big-endian signed integers"
> plus perhaps some String I/O with a few encodings.
> Alas, we do *not* have
> something in our standard libs, although there were
> a few discussions about
> it. I know that one can debate ages about byte
> orders, external representation
> of arrays and floats, etc. Nevertheless, I guess
> covering only low-/big-endian
> systems, IEEE 754 floats, and arrays as a simple
> 0-based sequence of its
> elements (with an explicit length stated somehow)
> would make at least 90% of all
> users happy and would be sufficient for most "real
> world" file formats. Currently
> one is bound to hGetBuf/hPutBuf, which is not really
> a comfortable way of doing
> binary I/O.
Basically, I just want to have a function, that
converts a list with zeros and ones to a binary file
and the other way around.
If I write 11111111 to a file, it would take 8 bytes.
But I want it to take 8 bits.
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
More information about the Haskell-Cafe