output-irc only.Expand description
mIRC ^C color-code export backend (E012 US2 — FR-006, FR-015, FR-027).
§Format
mIRC encodes colors as a ^C (0x03) prefix followed by 1-2 decimal
digits selecting the foreground palette index from the 16-color
standard table (0..=15). Optionally a ,BB suffix selects the
background. Reset is ^O (0x0F).
§Non-printable stripping (FR-015)
ASCII C0 control bytes (0x00..=0x1F except 0x09 tab) and the
C1 range (0x7F..=0x9F) are stripped from cell text per FR-015.
UTF-8 multibyte continuation bytes (0x80..=0xBF) are PRESERVED
when they’re part of a valid UTF-8 sequence — we operate on &str,
not &[u8], so the standard library has already validated UTF-8
boundaries before we see the input. The C1 range only intersects
the continuation range, but bytes that appear as the start of
a multi-byte sequence won’t be in 0x80..=0x9F (UTF-8 leaders are
0xC2..=0xF4).
In practical terms: iterating .chars() gives us validated
codepoints, and we strip the BMP code-point if (c as u32) < 0x20 && c != '\t' OR c == '\x7F' OR (c as u32 >= 0x80 && c as u32 <= 0x9F).
§Pre-sized writer (FR-027)
Single-pass: we iterate cells once and emit both color codes and
text bytes in the same loop. Vec<u8>::with_capacity(w * h * 6)
covers ^C99,99X (the longest per-cell encoding).
§Warn-on-strip
The CLI flag --warn-irc-strip is wired in Phase 9 (T060). This
module accepts a boolean warn_on_strip parameter; when true the
function emits a single deduplicated stderr warning if any byte
was stripped during this call.
Functions§
- write_
irc - Encode
gridas a sequence of mIRC^Ccolor-coded bytes per FR-006 + FR-015 + FR-027.