SQLite Forum

Endianness help
# The simplified version

You don't store a file using the endianness your processor uses.   Think of the endianness your processor uses as a purely internal matter.  Unless something reads data directly from the memory on your motherboard, nothing else cares, or will even notice.

The specification for a storage medium (e.g. a memory stick), or for a file format, or for a protocol, will specify what endianness should be used.  The software/firmware which gets data to it, or reads data from it, will make sure that bits, octets, words, streams, arrive where they're going in the right order.  This is necessary to ensure, for example, that a memory stick can be written on a little-endian system but read on a big-endian system.

# Some of the many complications

Some storage media, file formats, or protocols, allow for data to be arranged either way around.  For these there is a flag which says which way around the next piece of data (or perhaps the entire file) is.

Exactly where end-swapping is done – in software, hardware, at OS or application level, or inside the storage system – differs in different systems.  The fastest or most convenient way to do it has changed over the years and continues to change with advances in hardware and software.

# The overriding message
(which is what I should have written instead of the above)

This has nothing to do with SQLite unless you're trying to read SQLite files without using the SQLite API.  If you want to learn how things like this are done, take a computing course at university level, or read the text books used for such a course.  Programming is a profession.  It requires training and experience.  You can't pick it all up from online chat sites, which is why Stackoverflow doesn't help.