Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

/p/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/x/daily/hexdump/v0

Directory · 4 Files
README.md Open

gno.land/p/moul/x/daily/hexdump/v0

Classic xxd -C byte dump — Dump, DumpString, Line, Offset, Hex, ASCII, Printable, MaxBytes, BytesPerLine.

1import "gno.land/p/moul/x/daily/hexdump/v0"
2
3out, n := hexdump.DumpString("café")
4// 00000000  63 61 66 c3 a9                                    |caf..|
5// n == 5 — "é" is two bytes

The familiar layout: 8-digit hex offset, 16 bytes as hex in two 8-byte groups, then the ASCII view between pipes with non-printables as .. Short final lines are padded so the ASCII gutter never shifts — that alignment is the whole point of the format, and it has its own test asserting the gutter lands in the same column on a full and a partial line.

Useful on chain for the same reason it is useful off it: when a value is not what you expected, the bytes tell you why. Trailing whitespace, stray NULs, UTF-8 that is not what it claims — all invisible in a rendered string and obvious in a dump.

Dump returns the number of bytes rendered alongside the text, so truncation at MaxBytes (4096) is reported rather than silent.

Live demo: r/moul/x/daily/hexdumpdemo · render it at /r/moul/x/daily/hexdumpdemo/v0.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.