Character type
The char type represents a single Unicode scalar value (i.e., a code point that is not a surrogate).
Example
#![allow(unused)] fn main() { let c: char = 'a'; let emoji: char = '😀'; let unicode: char = '\u{1F600}'; }
Note
See the standard library docs for information on the impls of the
chartype.
A value of type char is represented as a 32-bit unsigned word in the 0x0000 to 0xD7FF or 0xE000 to 0x10FFFF range. It is immediate undefined behavior to create a char that falls outside this range.
char is guaranteed to have the same size and alignment as u32 on all platforms.
Every byte of a char is guaranteed to be initialized. In other words, transmute::<char, [u8; size_of::<char>()]>(...) is always sound – but since some bit patterns are invalid chars, the inverse is not always sound.