Edit Anything

Professional text and hex editing
with Binary Templates technology.

SweetScape Knowledgebase

KB1030: How does endianness work for templates?

Endianness refers to the byte order when reading data from a file. Binary data can either be stored in big-endian or little-endian mode (for more information on endian see 'Introduction to Byte Ordering' in the 010 Editor manual). For example, if a 'ushort' variable was read from the hex bytes 'FF 00', its value would be 256 in little-endian mode but 65280 in big-endian mode.

Every Template has a current endian setting and each variable that gets defined is set to that endian. By default, the current endian is the endian from the current file setting (you should see 'LIT' in the status bar if your file is in little-endian mode, or 'BIG' in the status bar if your file is in big-endian mode). This endian is set when a file is opened by the current 'File Interface' and can be changed using the 'View > Endian' menu or the shortcuts 'Ctrl+E', or 'Ctrl+Shift+E'.

It is possible to switch to a different endian setting using the 'BigEndian();' or 'LittleEndian();' functions. If your binary format is always defined in a particular endian, it is a good idea to call the appropriate endian function at the start of your template. All variables defined after a call to 'BigEndian();' or 'LittleEndian();' will use that endian setting. It is even possible to mix big and little-endian data in a single file. For example:

     int bigInt;
     int littleInt;

Newsletter - Receive special offers, tips, tricks and news. Join now

010 Editor v14.0.1 is here!
What's new?



010 Editor

E-mail: info@sweetscape.com