Function utf_16_le_to_utf_8

Source
pub fn utf_16_le_to_utf_8(
    input: &[u16],
    output_count: &mut usize,
    output: &mut [u8],
) -> bool
Examples found in repository?
examples/test_utf_16_to_utf_8.rs (line 33)
5fn main() {
6    let input_1: [u16; 5] = [0xFEFF, 0x0001, 0x0002, 0x0003, 0x00A9];
7    let input_2: [u16; 5] = [0xFEFF, 0x0001, 0x0002, 0x0003, 0x00A9];
8    let input_3: [u16; 5] = [0xFFFE, 0x0100, 0x0200, 0x0300, 0xA900];
9    let mut output_count: usize = 0;
10    let mut output: [u8; 15] = [0; 15];
11    let mut i: usize = 0;
12
13    if utf_16_to_utf_8(&input_1, &mut output_count, &mut output) == true {
14        while i != output_count {
15            println!("0x{:02X}", output[i]);
16            i += 1;
17        }
18    }
19
20    println!("");
21
22    if utf_16_be_to_utf_8(&input_2, &mut output_count, &mut output) == true {
23        i = 0;
24
25        while i != output_count {
26            println!("0x{:02X}", output[i]);
27            i += 1;
28        }
29    }
30
31    println!("");
32
33    if utf_16_le_to_utf_8(&input_3, &mut output_count, &mut output) == true {
34        i = 0;
35
36        while i != output_count {
37            println!("0x{:02X}", output[i]);
38            i += 1;
39        }
40    }
41}