Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
char32_t is a fundamental, distinct character type in C++ (introduced in C++11) designed to represent a single UTF-32 character code unit. Because UTF-32 is a fixed-width encoding at the code point level, a single char32_t value directly corresponds to a single Unicode scalar value (code point).
Type Specifications
- Size and Signedness:
char32_thas the exact same size, signedness, and alignment requirements asstd::uint_least32_t. It is an unsigned integral type guaranteed to be at least 32 bits wide. Note thatsizeof(char32_t)returns the size in C++ bytes, which depends on the platformβsCHAR_BITmacro; therefore, it is not strictly guaranteed to be 4 bytes on platforms where a byte is larger than 8 bits. - Type Distinctness: Despite its underlying representation,
char32_tis a distinct type. It is not atypedefforstd::uint_least32_t, meaning it resolves uniquely during function overloading and template specialization.
Literal Syntax
To declare achar32_t character or string literal, prefix the literal with a capital U.
Standard Library Integration
The C++ Standard Library provides specialized aliases and templates to handlechar32_t sequences:
Memory Representation and Code Points
Achar32_t array or std::u32string stores sequences of integers that are at least 32 bits wide. Unlike char8_t (UTF-8), which requires variable-length sequences for almost all code points (anything above U+007F), or char16_t (UTF-16), which requires variable-length surrogate pairs for code points outside the Basic Multilingual Plane (BMP), every valid Unicode code point fits into exactly one char32_t element.
It is critical to distinguish between a Unicode code point and a user-perceived character (grapheme cluster). While char32_t avoids surrogate pairs, grapheme clusters containing combining diacritical marks, skin tone modifiers, or zero-width joiners (ZWJ) consist of multiple code points and will therefore require multiple char32_t elements.
Standard I/O Limitations
Standard C++ I/O streams do not provide built-in support forchar32_t. There is no std::u32cout stream, and std::ostream lacks overloaded operator<< functions for char32_t strings or characters. Attempting to print these types directly will result in compilation errors or unintended behavior.
Master C++ with Deep Grasping Methodology!Learn More





