Not sure if this is exactly what you are asking for, but, for example, the PCAP file format indicates the endianness variable:
http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html
The concept is that you can write a marker byte, for example 0x12345678, in the header of your file. On a "large endian" machine, such as PowerPC, it will be written as follows:
0x12 0x34 0x56 0x78
On a "small destination" machine, such as x86, it will be written as follows:
0x78 0x56 0x34 0x12
Then, when you read your header, you can find out which machine you read to determine if you need to change the bytes when reading the file. Or you can specify a continent, for example, a large endian. Then you will always change the bytes on the small destination machine.
In the case of the PCAP format, this was done for performance reasons. But it is probably easier to point and confirm and stick to it.
source share