Expand description
Strict decode / encode / transcode (DESIGN.md §4).
Invariants enforced here:
- UTF-16 encoders never emit a BOM by themselves — the BOM is prepended
manually by
encode(invariant #2). - Any decode that reports
had_errorsis a hard error, never a replacement-char pass-through (invariant #7). - No newline normalization —
encoding_rspreserves\r\nverbatim (invariant #3).
Enums§
- Target
Encoding - Encodings the tool can write.
- Transcode
Outcome - Result of transcoding a byte stream.
Functions§
- decode_
strict - Strictly decode
bytesaccording to a priordetectverdict. - encode
- Encode
textintotarget. BOMs forutf-8-bom/utf-16le/utf-16beare prepended manually —encoding_rsnever emits them. - transcode
- Detect + transcode in one call. Prefer
transcode_detectedwhen the detection verdict is already known (avoids a second sniff). - transcode_
detected - Transcode with a pre-computed detection verdict.