Single character
examples/chars/single/src/main.rs
fn main() { let chars = ['1', 'a', 'ื', 'ฮฉ', '๐', '๐']; for ch in chars { let usize_num = ch as usize; let u32_num = ch as u32; let back = char::from_u32(u32_num).expect("Could not convert to char"); println!( "{ch}\t{usize_num:6} {u32_num:6} {back} \t{} {}", (ch == back), ch.len_utf8() ); } }
1 49 49 1 true 1 a 97 97 a true 1 ื 1488 1488 ื true 2 ฮฉ 937 937 ฮฉ true 2 ๐ 128519 128519 ๐ true 4 ๐ 128520 128520 ๐ true 4