Content-Length: 27754 | pFad | https://doc.rust-lang.org/std/string/../str/pattern/../../string/../../reference/types/char.html

Character type - The Rust Reference

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 char type.

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.









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../str/pattern/../../string/../../reference/types/char.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy