
4 Oct
2005
4 Oct
'05
5:31 a.m.
On 10/3/05, Udo Stenzel
Joel Reymont wrote:
Are there any endian conversion routines for Haskell? I'm looking to build binary packets on top of NewBinary.Binary but my data is coming in little-endian whereas I'll need to send it out big endian.
Why don't you pull out 4 bytes and assemble them manually? Three shifts, logical ors and fromIntegrals aren't that much of a burden after all.
Exactly! Network encodings for integers are precisely, mathematically defined. Surprisingly, it is very difficult to see (it was a revelation for me too). Perhaps the reason is that people get used to the mess in C networking code. Best regards Tomasz