pub struct Decoder { /* private fields */ }
Expand description
Decoder of byte slices into strings.
If feature encoding
is enabled, this encoding taken from the "encoding"
XML declaration or assumes UTF-8, if XML has no declaration, encoding
key is not defined or contains unknown encoding.
The library supports any UTF-8 compatible encodings that crate encoding_rs
is supported. UTF-16 and ISO-2022-JP are not supported at the present.
If feature encoding
is disabled, the decoder is always UTF-8 decoder:
any XML declarations are ignored.
Implementations
sourceimpl Decoder
impl Decoder
sourcepub fn encoding(&self) -> &'static Encoding
Available on crate feature encoding
only.
pub fn encoding(&self) -> &'static Encoding
encoding
only.Returns the Reader
s encoding.
This encoding will be used by decode
.
sourcepub fn decode<'b>(&self, bytes: &'b [u8]) -> Result<Cow<'b, str>>
pub fn decode<'b>(&self, bytes: &'b [u8]) -> Result<Cow<'b, str>>
Without encoding
feature
Decodes an UTF-8 slice regardless of XML declaration and ignoring BOM
if it is present in the bytes
.
With encoding
feature
Decodes specified bytes using encoding, declared in the XML, if it was
declared there, or UTF-8 otherwise, and ignoring BOM if it is present
in the bytes
.
Returns an error in case of malformed sequences in the bytes
.