Skip to main content

Module transcoder

Module transcoder 

Source
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_errors is a hard error, never a replacement-char pass-through (invariant #7).
  • No newline normalization — encoding_rs preserves \r\n verbatim (invariant #3).

Enums§

TargetEncoding
Encodings the tool can write.
TranscodeOutcome
Result of transcoding a byte stream.

Functions§

decode_strict
Strictly decode bytes according to a prior detect verdict.
encode
Encode text into target. BOMs for utf-8-bom / utf-16le / utf-16be are prepended manually — encoding_rs never emits them.
transcode
Detect + transcode in one call. Prefer transcode_detected when the detection verdict is already known (avoids a second sniff).
transcode_detected
Transcode with a pre-computed detection verdict.