Formatting Binary Data for Inspection
A byte dump should make offsets, widths, and byte boundaries visible so readers can tell where a representation changes.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Choose a representation
Bytes 00, 08, and A3 retain their leading hexadecimal zero digits in a fixed-width dump. Byte 08 at offset one is an observation distinct from the numeric value eight alone. Hexadecimal byte spelling preserves both meaning and width.
Compare a known record
Show a header and payload separately when their formats differ. If a supposed one-byte length occupies two observed positions, check the offset rule before parsing the value. Reading a length field gives a concrete header example.[1]
Keep offsets, byte values and text interpretation distinct
The four bytes 41 00 C3 A9 can show ASCII A at offset zero, a null byte, and two bytes encoding é in UTF-8. A printable column showing individual byte values may represent the last two with placeholders. Keep such a display separate from decoding the underlying stream. See encoding round trips.
Offset Bytes ASCII display
0000 41 00 C3 A9 A...
Decode as UTF-8: A, U+0000, U+00E9
Verify the layout on partial final rows
When a dump groups sixteen bytes per line, the last line can be shorter. Display offsets in a stated base and preserve leading zeros in bytes. Test a nonprintable byte and a multibyte character crossing a row boundary.