Mac OS provides two routines that help you swap bytes between big-endian and little-endian data formats:
UInt16 EndianSwap16Bit (UInt16 data16);
UInt32 EndianSwap32Bit (UInt32 data32);
EndianSwap16Bit and EndianSwap32Bit return byte swapped versions of their input values, thereby converting big-endian data to little-endian or little-endian data to big-endian.