Function widestring::decode_utf32
source · pub fn decode_utf32<I: IntoIterator<Item = u32>>(
iter: I,
) -> DecodeUtf32<I::IntoIter> ⓘ
Expand description
Creates a decoder iterator over UTF-32 encoded code points in iter
, returning invalid values
as Err
s.
§Examples
use widestring::decode_utf32;
// 𝄞mus<invalid>ic<invalid>
let v = [
0x1D11E, 0x6d, 0x75, 0x73, 0xDD1E, 0x69, 0x63, 0x23FD5A,
];
assert_eq!(
decode_utf32(v.iter().copied())
.map(|r| r.map_err(|e| e.invalid_code_point()))
.collect::<Vec<_>>(),
vec![
Ok('𝄞'),
Ok('m'), Ok('u'), Ok('s'),
Err(0xDD1E),
Ok('i'), Ok('c'),
Err(0x23FD5A)
]
);