pub fn try_parse_utf8_char(input: &[u8]) -> Option<(char, usize)>
Expand description
Attempts to parse a UTF-8 character from the given byte slice.
The function returns the parsed character and the number of bytes consumed.
ยงExamples
use television_utils::strings::try_parse_utf8_char;
let input = b"Hello, World!";
let (chr, n) = try_parse_utf8_char(input).unwrap();
assert_eq!(chr, 'H');
assert_eq!(n, 1);
let input = b"\xF0\x9F\x91\x8B\xF0\x9F\x8C\x8D!";
let (chr, n) = try_parse_utf8_char(input).unwrap();
assert_eq!(chr, '๐');
assert_eq!(n, 4);