module
C0::Pretty
Overview
Unicode Control Pictures (U+2400 block) for pretty-printing. Each C0 code at position N maps to U+2400+N.
Defined in:
c0/pretty.crConstant Summary
-
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 Method Summary
-
.align(pretty : String, mode : FormatMode = FormatMode::Spaced) : String
Reformat a pretty-form string with column alignment.
-
.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.
-
.format(buf : Bytes, io : IO, indent : String = " ", mode : FormatMode = FormatMode::Compact) : Nil
Format to an IO.
-
.glyph(byte : UInt8) : Char
Convert a C0 control byte to its Unicode Control Picture character.
-
.parse(str : String) : Bytes
Parse pretty-form back to compact form.
Class Method Detail
Reformat a pretty-form string with column alignment.
Modes:
Aligned— column alignment onlySpaced— column alignment + space after prefix + space around ␟
def self.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.
def self.format(buf : Bytes, io : IO, indent : String = " ", mode : FormatMode = FormatMode::Compact) : Nil
#
Format to an IO.
def self.glyph(byte : UInt8) : Char
#
Convert a C0 control byte to its Unicode Control Picture character.
def self.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.