Function collections::str::from_utf16_lossy[src]

pub fn from_utf16_lossy(v: &[u16]) -> String

Decode a UTF-16 encoded vector v into a string, replacing invalid data with the replacement character (U+FFFD).

Example

fn main() { use std::str; // 𝄞mus<invalid>ic<invalid> let v = [0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0xDD1E, 0x0069, 0x0063, 0xD834]; assert_eq!(str::from_utf16_lossy(v), "𝄞mus\uFFFDic\uFFFD".to_string()); }
use std::str;

// 𝄞mus<invalid>ic<invalid>
let v = [0xD834, 0xDD1E, 0x006d, 0x0075,
         0x0073, 0xDD1E, 0x0069, 0x0063,
         0xD834];

assert_eq!(str::from_utf16_lossy(v),
           "𝄞mus\uFFFDic\uFFFD".to_string());