std-method
char::from_u32
Convert a numeric value only if it represents a Unicode scalar; surrogate values and values above U+10FFFF are rejected. Expected stdout (not executed): ی true Common mistake: Casting arbitrary integers directly to char.
Formal Syntax & Structure
rust syntaxrust
char::from_u32(n: u32) -> Option<char>Working Example
Example Snippetrust
fn main() { println!("{}", char::from_u32(0x06CC).unwrap()); println!("{}", char::from_u32(0xD800).is_none());}