Skip to main content

Module transcoder

Module transcoder 

Source
Expand description

Strict decode / encode / transcode.

Rules enforced here:

  • UTF-16 encoders never emit a BOM by themselves — encode prepends it manually.
  • Any decode that reports had_errors is a hard error, never a replacement-char pass-through, so mojibake is never written.
  • No newline normalization — encoding_rs preserves \r\n verbatim.

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.