Page 2 of 2
Re: Endians
Posted: Mon Feb 04, 2013 4:24 am
by Love4Boobies
Implementations are likely have different internal representations. So, if you need to prepare some data for processing on a different implementation, you require a common format. The party preparing and encoding the data is said to serialize it, while the party decoding and processing it is said to deserialize it.
Re: Endians
Posted: Mon Feb 04, 2013 5:31 am
by qw
All right, I did not know the meaning of "serialization" in this context.
So to properly serialize or deserialize, one must know the internal representation. Or the library should supply some functions that are endian-aware (like ntohl() and relatives).
Re: Endians
Posted: Mon Feb 04, 2013 5:33 am
by Love4Boobies
Precisely.
Re: Endians
Posted: Mon Feb 04, 2013 5:13 pm
by Brendan
Hi,
Hobbes wrote:So to properly serialize or deserialize, one must know the internal representation. Or the library should supply some functions that are endian-aware (like ntohl() and relatives).
Things like network packets and files are really arrays of bytes. If you treat them as arrays of bytes then you end up writing code (like "buffer[0] = myInt & 0xFF; buffer[1] = (myInt >> 8 ) & 0xFF;") to do type conversion correctly, and any endian problem disappears by accident.
From this perspective you could say that endian problems are actually "lack of strong type checking" problems.
Cheers,
Brendan