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