Skip to main content

Crate utf8_zero

Crate utf8_zero 

Source
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 &str slices, replacing errors with U+FFFD.
  • BufReadDecoder (requires the std feature) – a pull-based streaming decoder wrapping any std::io::BufRead, with both strict and lossy modes.

Structs§

BufReadDecoder
Wraps a std::io::BufRead buffered byte stream and decode it as UTF-8.
Incomplete
An incomplete byte sequence for a multi-byte UTF-8 code point.
LossyDecoder
A push-based, lossy decoder for UTF-8. Errors are replaced with the U+FFFD replacement character.

Enums§

BufReadDecoderError
Error returned by BufReadDecoder::next_strict().
DecodeError
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.