Expand description
The compat API flavor provides full compatibility with std::str::from_utf8() and detailed validation errors.
In particular, from_utf8()
returns an Utf8Error, which has the valid_up_to() and
error_len() methods. The first is useful for verification of streamed data. The
second is useful e.g. for replacing invalid byte sequences with a replacement character.
The functions in this module also fail early: errors are checked on-the-fly as the string is processed and once
an invalid UTF-8 sequence is encountered, it returns without processing the rest of the data.
This comes at a slight performance penalty compared to the crate::basic module if the input is valid UTF-8.
Structs§
- Utf8
Error - UTF-8 error information compatible with
std::str::Utf8Error.
Functions§
- from_
utf8 - Analogue to
std::str::from_utf8(). - from_
utf8_ mut - Analogue to
std::str::from_utf8_mut().