[Haskell-cafe] Data.Binary Endianness
jules at jellybean.co.uk
Mon Sep 10 06:10:58 EDT 2007
Adrian Neumann wrote:
> For example, the internet states, that the magic number, that puts 'BM'
> in the first two bytes of the file is 19778. But when I
>> put (19778::Word16)
> I get 'MB' instead. I read on the german Wikipedia, that bmp uses little
> endian encoding, but Data.Binary uses big endian. Obviously this can't work.
Data.Binary is two different things. This is not as well explained as it
(a) a binary read/write layer for haskell types, which uses its own
formats you have no right to complain about
(b) a simple efficient binary bitstream layer
You don't want to use (a), which takes great care to use compatible
endianness to make sure its output can be read on other architectures.
(b) however lets you choose your endianness.
The docs are not as well interlinked as you might hope.
More information about the Haskell-Cafe