/// Creates a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
///
/// This is lossless: calling `.encode_wide()` on the resulting string
/// will always return the original code units.
Creates a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
This is lossless: calling `.encode_wide()` on the resulting string
will always return the original code units.
Creates a WTF - 8 string from a potentially ill - formed UTF - 16 slice of 16 - bit code units . This is lossless : calling ` . encode_wide () ` on the resulting string will always return the original code units .
pub fn from_wide(v: &[u16]) -> Wtf8Buf {
        let mut string = Wtf8Buf::with_capacity(v.len());
        for item in char::decode_utf16(v.iter().cloned()) {
            match item {
                Ok(ch) => string.push_char(ch),
                Err(surrogate) => {
                    let surrogate = surrogate.unpaired_surrogate();
                    // Surrogates are known to be in the code point range.
                    let code_point = unsafe { CodePoint::from_u32_unchecked(surrogate as u32) };
                    // Skip the WTF-8 concatenation check,
                    // surrogate pairs are already decoded by decode_utf16
                    string.push_code_point_unchecked(code_point)
                }
            }
        }
        string
    }
pub fn from_wide ( v : & [ u16 ] ) -> Wtf8Buf { let mut string = Wtf8Buf :: with_capacity ( v . len ( ) ) ; for item in char :: decode_utf16 ( v . iter ( ) . cloned ( ) ) { match item { Ok ( ch ) => string . push_char ( ch ) , Err ( surrogate ) => { let surrogate = surrogate . unpaired_surrogate ( ) ; // Surrogates are known to be in the code point range. let code_point = unsafe { CodePoint :: from_u32_unchecked ( surrogate as u32 ) } ; // Skip the WTF-8 concatenation check, // surrogate pairs are already decoded by decode_utf16 string . push_code_point_unchecked ( code_point ) } } } string }
Creates a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units.
Creates a WTF - 8 string from a potentially ill - formed UTF - 16 slice of 16 - bit code units .
v
&[u16]