encode_in_utf16

Function encode_in_utf16 

Source
pub fn encode_in_utf16<T: AsRef<Vec<u32>>>(unicode_cp: T) -> Vec<u16>
Expand description

Encode a vector of unicode code points into a vector of UTF-16 code points.

§Parameters

  • unicode_cp: Vec<u32> - A vector of unicode code points.

§Returns

A Vec<u16> containing the UTF-16 code points.

§Panics

  • If the input vector (unicode_cp) of unicode code points contains invalid unicode code points.

§Example

use ende::prelude::*;
let v: Vec<u32> = vec![0x10001]; // Array of code points in unicode
let enc: Vec<u16> = encode_in_utf16(&v);
assert_eq!(enc, vec![0xD800, 0xDC01]);