Function widestring::decode_utf32_lossy

source ·
pub fn decode_utf32_lossy<I: IntoIterator<Item = u32>>(
    iter: I,
) -> DecodeUtf32Lossy<I::IntoIter> 
Expand description

Creates a lossy decoder iterator over the possibly ill-formed UTF-32 encoded code points in iter.

This is equivalent to decode_utf32 except that any invalid UTF-32 values are replaced by U+FFFD REPLACEMENT_CHARACTER (�) instead of returning errors.

§Examples

use widestring::decode_utf32_lossy;

// 𝄞mus<invalid>ic<invalid>
let v = [
    0x1D11E, 0x6d, 0x75, 0x73, 0xDD1E, 0x69, 0x63, 0x23FD5A,
];

assert_eq!(
decode_utf32_lossy(v.iter().copied()).collect::<String>(),
"𝄞mus�ic�"
);