Expand description
Zero-copy, incremental UTF-8 decoding with error handling.
Three levels of API:
decode()– low-level, single-shot decode of a byte slice. Returns the valid prefix and either an invalid sequence or an incomplete suffix that can be completed with more input.LossyDecoder– a push-based streaming decoder. Feed it chunks of bytes and it calls back with&strslices, replacing errors with U+FFFD.BufReadDecoder(requires thestdfeature) – a pull-based streaming decoder wrapping anystd::io::BufRead, with both strict and lossy modes.
Structs§
- BufRead
Decoder - Wraps a
std::io::BufReadbuffered byte stream and decode it as UTF-8. - Incomplete
- An incomplete byte sequence for a multi-byte UTF-8 code point.
- Lossy
Decoder - A push-based, lossy decoder for UTF-8. Errors are replaced with the U+FFFD replacement character.
Enums§
- BufRead
Decoder Error - Error returned by
BufReadDecoder::next_strict(). - Decode
Error - Error from
decode()when the input is not entirely valid UTF-8.
Constants§
- REPLACEMENT_
CHARACTER - The replacement character, U+FFFD. In lossy decoding, insert it for every decoding error.
Functions§
- decode
- Decode a byte slice as UTF-8, returning the valid prefix on error.