Struct utf8::Decoder
[−]
[src]
pub struct Decoder {
// some fields omitted
}A low-level, zero-copy UTF-8 decoder with error handling.
This decoder can process input one chunk at a time,
returns &str Unicode slices into the given &[u8] bytes input,
and stops at each error to let the caller deal with it however they choose.
Methods
impl Decoder[src]
fn new() -> Decoder
fn has_incomplete_sequence(&self) -> bool
Return whether the input of the last call to .decode() ended with an incomplete
UTF-8 sequence for a code point.
If this is true and there is no more input, this is a decoding error.
fn decode<'a>(&mut self, input_chunk: &'a [u8]) -> (StringWrapper<[u8; 4]>, &'a str, Result<'a>)
Start decoding one chunk of input bytes. The return value is a tuple of:
- An inline buffer of up to 4 bytes that dereferences to
&str. When the length is non-zero, it represents a single code point that was re-assembled from multiple input chunks. - The Unicode slice of at the start of the input bytes chunk that is well-formed UTF-8. May be empty, for example when a decoding error occurs immediately after another.
- Details about the rest of the input chuck. See the documentation of the
Resultenum.