pub fn detect_encoding(bytes: &[u8]) -> EncodingExpand description
Detect the encoding of a YAML byte stream via BOM or null-byte heuristic.
Implements YAML 1.2 ยง5.2 encoding detection. UTF-32 BOMs are checked
before UTF-16 because the UTF-32 LE BOM (FF FE 00 00) is a superset of
the UTF-16 LE BOM (FF FE). The same prefix-overlap reasoning applies to
BOM-less heuristics: UTF-32 null-byte patterns must come before UTF-16
null-byte patterns because [a, 0x00, 0x00, 0x00, ..] (UTF-32-LE) is a
strict superset of [a, 0x00, ..] (UTF-16-LE).