Function rustc_unicode::str::utf16_items [] [src]

pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a>
Deprecated since 1.4.0

: renamed to char::decode_utf16

Create an iterator over the UTF-16 encoded codepoints in v, returning invalid surrogates as LoneSurrogates.

Examples

#![feature(unicode, decode_utf16)] #![allow(deprecated)] extern crate rustc_unicode; use rustc_unicode::str::Utf16Item::{ScalarValue, LoneSurrogate}; fn main() { // 𝄞mus<invalid>ic<invalid> let v = [0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0xDD1E, 0x0069, 0x0063, 0xD834]; assert_eq!(rustc_unicode::str::utf16_items(&v).collect::<Vec<_>>(), vec![ScalarValue('𝄞'), ScalarValue('m'), ScalarValue('u'), ScalarValue('s'), LoneSurrogate(0xDD1E), ScalarValue('i'), ScalarValue('c'), LoneSurrogate(0xD834)]); }
#![feature(unicode, decode_utf16)]

extern crate rustc_unicode;

use rustc_unicode::str::Utf16Item::{ScalarValue, LoneSurrogate};

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

    assert_eq!(rustc_unicode::str::utf16_items(&v).collect::<Vec<_>>(),
               vec![ScalarValue('𝄞'),
                    ScalarValue('m'), ScalarValue('u'), ScalarValue('s'),
                    LoneSurrogate(0xDD1E),
                    ScalarValue('i'), ScalarValue('c'),
                    LoneSurrogate(0xD834)]);
}