pub fn detect(bytes: &[u8]) -> DetectedEncodingExpand description
Classify raw bytes. Rule-based on purpose — no statistical guessing.
The UTF-32 BOMs (FF FE 00 00 LE / 00 00 FE FF BE) are checked before
the 2-byte UTF-16 BOMs (longest-prefix precedence, as in WHATWG BOM
sniffing). Documented consequence: a UTF-16LE file whose first character
is U+0000 shares its leading bytes with the UTF-32LE BOM; such a payload
fails the strict UTF-32 decode loudly (decode_error) instead of being
silently transcoded, so a detection ambiguity never produces mojibake.