pub fn decode(
bytes: &[u8],
charset: Charset,
byte_order: ByteOrder,
) -> Result<Cow<'_, str>, InvalidText>Expand description
Decodes bytes as charset.
Single-byte ASCII-compatible input is returned borrowed; anything needing transcoding allocates.
§Errors
Returns InvalidText if the bytes are not a valid encoding of text in charset.
Latin-1 and Windows-1252 have no invalid sequences except the five undefined
Windows-1252 code points, which are rejected — matching Python’s bytes.decode, and for
the same reason: silently substituting a replacement character would turn a corrupt field
into a plausible-looking string.