Skip to content

Repository files navigation

hexd :octocat:

Creates a hex dump of any file you provide it. A clone of xxd with an added utf-8 dump mode (from scratch).

Usage

./hexd <filename> <-hex|-utf8>

Both arguments are required! Errors go to stderr and exit status is 0 on success and 1 on failure.

Modes

-hex

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 ..

-utf8

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+D800U+DFFF
  • Above U+10FFFF
  • Sequence truncated by EOF

About

A from-scratch xxd clone with an added utf-8 dump. Parses raw bytes into hex or UTF-8 dumps, validating encoding errors (invalid continuation bytes, overlong sequences, truncated input)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages