module

C0::Pretty

Unicode Control Pictures (U+2400 block) for pretty-printing. Each C0 code at position N maps to U+2400+N.

Constants

G_DLE = glyph(DLE)
G_EOT = glyph(EOT)
G_FS = glyph(FS)
G_GS = glyph(GS)
G_RS = glyph(RS)
G_SOH = glyph(SOH)
G_US = glyph(US)
PREFIXES = Set {G_FS, G_GS, G_RS, G_SOH, G_US}

Class methods

align(pretty : String, mode : FormatMode = FormatMode::Spaced) : String

Reformat a pretty-form string with column alignment.

Modes:

  • Aligned — column alignment only
  • Spaced — column alignment + space after prefix + space around ␟
Source
format(buf : Bytes, indent : String = " ", mode : FormatMode = FormatMode::Compact) : String

Format a compact C0DATA buffer as a human-readable Unicode string with newlines and indentation.

Source
format(buf : Bytes, io : IO, indent : String = " ", mode : FormatMode = FormatMode::Compact) : Nil

Format to an IO.

Source
glyph(byte : UInt8) : Char

Convert a C0 control byte to its Unicode Control Picture character.

Source
parse(str : String) : Bytes

Parse pretty-form back to compact form.

Rules:

  • Unicode Control Pictures (U+2400-U+241F) → C0 bytes
  • LF/CR are ignored (formatting only)
  • Whitespace (space/tab) adjacent to control codes is trimmed
  • Inside STX/ETX (␂...␃), everything is preserved verbatim (no trimming). This allows STX/ETX to serve as quoting for values with significant whitespace.
Source

Nested types