pub enum ByteOrderGuess {
Utf8,
Utf16Le,
Utf16Be,
Utf32Le,
Utf32Be,
Utf32Order2143,
Utf32Order3412,
Ebcdic,
}Expand description
The coarse encoding family implied purely by the first few bytes of an XML entity, before any
attempt to read an encoding="..." declaration.
This mirrors the byte-pattern table of XML 1.0 Appendix F.1 in full, including the UTF-32 and
EBCDIC patterns that this crate cannot itself decode (Encoding has no such variants) —
recognizing the pattern is still useful so a caller can produce a precise diagnostic (“this
looks like EBCDIC, which is unsupported”) instead of a generic decode failure. Use
ByteOrderGuess::supported_encoding to get the Encoding this crate can actually decode
with, if any.
Variants§
Utf8
EF BB BF (BOM) or 3C 3F 78 6D (<?xm as ASCII/UTF-8/Latin-1/windows-1252/…).
Utf16Le
FF FE (BOM) or 3C 00 3F 00 (<?xm as UTF-16, little-endian, no BOM).
Utf16Be
FE FF (BOM) or 00 3C 00 3F (<?xm as UTF-16, big-endian, no BOM).
Utf32Le
FF FE 00 00: UTF-32, little-endian. Not decodable by this crate.
Utf32Be
00 00 FE FF: UTF-32, big-endian. Not decodable by this crate.
Utf32Order2143
00 00 FF FE: UTF-32 with an unusual 2-1-4-3 octet order. Not decodable by this crate.
Utf32Order3412
FE FF 00 00: UTF-32 with an unusual 3-4-1-2 octet order. Not decodable by this crate.
Ebcdic
4C 6F A7 94 (<?xm in an EBCDIC code page). Not decodable by this crate.
Implementations§
Source§impl ByteOrderGuess
impl ByteOrderGuess
Sourcepub const fn supported_encoding(self) -> Option<Encoding>
pub const fn supported_encoding(self) -> Option<Encoding>
The Encoding this crate can actually decode with for this guess, if any.
ByteOrderGuess::Utf8 maps to Encoding::Utf8 here as a transport guess only: at
this stage all that’s known is that the entity is ASCII-compatible, not specifically that
it is UTF-8 rather than, say, windows-1252 — SniffResult::declared_encoding (read from
the prologue) is what actually distinguishes those.