Function regex_automata::util::utf8::decode
source · pub(crate) fn decode(bytes: &[u8]) -> Option<Result<char, u8>>
Expand description
Decodes the next UTF-8 encoded codepoint from the given byte slice.
If no valid encoding of a codepoint exists at the beginning of the given byte slice, then the first byte is returned instead.
This returns None
if and only if bytes
is empty.
This never panics.
WARNING: This is not designed for performance. If you’re looking for a fast UTF-8 decoder, this is not it. If you feel like you need one in this crate, then please file an issue and discuss your use case.