Creates a hex dump of any file you provide it. A clone of xxd with an added utf-8 dump mode (from scratch).
./hexd <filename> <-hex|-utf8>
Both arguments are required! Errors go to stderr and exit status is 0 on success and 1 on failure.
16 bytes per line: offset, hex bytes, then ASCII with non-printable bytes shown as .
[offset] [hex dump] [ascii]
00000000: C2 A3 0A E4 B8 96 0A 68 C3 A9 6C 6C 6F 20 F0 9F .......h..llo ..
One character per line: offset, hex bytes, code point, and the character itself.
[offset] [hex dump] [codepoint] [character]
00000000: 41 U+0041 A
00000001: DF BF U+07FF ߿
00000003: 0A invalid -
00000004: C0 AF invalid -
A character is marked invalid if it is non-printable (e.g., C0/C1 control sets) or has improper format:
- Byte does not match any UTF-8 lead pattern
- Continuation byte does not begin with
10 - Overlong encoding (sequence is longer than needed for its code point)
- Surrogate range,
U+D800–U+DFFF - Above
U+10FFFF - Sequence truncated by EOF