UTF-32
UTF-32 (32-bit Unicode Transformation Format), sometimes called UCS-4, is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits (four bytes) per code point (but a number of leading bits must be zero as there are far fewer than 2 32 Unicode code points, actually needing only 21 bits). In contrast, all other Unicode transformation formats are variable-length encodings. Each 32-bit value in UTF-32 represents one Unicode code point and is exactly equal to that code point's numerical value. The main advantage of UTF-32 is that the Unicode code points are directly indexed. Finding the Nth code point in a sequence of code points is a constant-time operation. In contrast, a variable-length code requires linear-time to count N code points from the start of the string. This makes UTF-32 a simple replacement in code that uses integers that are incremented by one to examine each location in a string, as was commonly done for ASCII. Novice programmers often vastly...
UTF-32 (32-bit Unicode Transformation Format), sometimes called UCS-4, is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits (four bytes) per code point (but a number of leading bits must be zero as there are far fewer than 2 32 Unicode code points, actually needing only 21 bits). In contrast, all other Unicode transformation formats are variable-length encodings. Each 32-bit value in UTF-32 represents one Unicode code point and is exactly equal to that code point's numerical value. The main advantage of UTF-32 is that the Unicode code points are directly indexed. Finding the Nth code point in a sequence of code points is a constant-time operation. In contrast, a variable-length code requires linear-time to count N code points from the start of the string. This makes UTF-32 a simple replacement in code that uses integers that are incremented by one to examine each location in a string, as was commonly done for ASCII. Novice programmers often vastly overestimate how useful this is. The main disadvantage of UTF-32 is that it is space-inefficient, using four bytes per code point, including 11 bits that are always zero. Characters beyond the BMP are relatively rare in most texts (except, for example, in the case of texts with some popular emojis), and can typically be ignored for sizing estimates. This makes UTF-32 close to twice the size of UTF-16. It can be up to four times the size of UTF-8 depending on how many of the characters are in the ASCII subset. include char32_t UTF32_character = U'🔟'; // also written as U'\U0001F51F' std::u32string UTF32_string = U"UTF–32-encoded string"; // defined as `const char32_t*´ C# has a UTF32Encoding class which represents Unicode characters as bytes, rather than as a string.
References
- ^ "Choisir et appliquer un encodage de caractères" . www.w3.org (in French) . Retrieved 2024-11-11 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1731279600.0
- ^ Löwis, Martin. "PEP 393 -- Flexible String Representation" . python.org . Python . Retrieved 26 October 2014 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1795042800.0
- ^ JuliaStrings/LegacyStrings.jl: Legacy Unicode string types , JuliaStrings, 2019-05-17 , retrieved 2019-10-15 Wikipedia revision 1377743665, retrieved 2026-11-19 · 1571094000.0
- ^ "UTF-8 Everywhere" . utf8everywhere.org . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1795042800.0
- ^ "u32string" . cplusplus.com . Retrieved 2024-11-12 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1731366000.0
- ^ "String literal - cppreference.com" . en.cppreference.com . Retrieved 2024-11-14 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1731538800.0
- ^ dotnet-bot. "UTF32Encoding Class (System.Text)" . learn.microsoft.com . Retrieved 2024-11-27 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1732662000.0
- ^ "Publicly Available Standards - ISO/IEC 10646:2020" . ISO Standards . Retrieved 2021-10-12 . Clause 9.4: "Because surrogate code points are not UCS scalar values, UTF-32 code units in the range 0000 D800-0000 DFFF are ill-formed". Clause 4.57: "[UCS codespace] consisting of the integers from 0 to 10 FFFF (hexadecimal)". Clause 4.58: "[UCS scalar value] any UCS code point except high-surrogate and low-surrogate code points". Wikipedia revision 1377743665, retrieved 2026-11-19 · 1633993200.0
- ^ a b Constable, Peter (2001-06-13). "Mapping codepoints to Unicode encoding forms" . Computers and Writing Systems - SIL International . Retrieved 2022-10-03 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1664751600.0
- ^ "Annex B - The Universal Character Set (UCS)" . DKUUG Standardizing . Archived from the original on Jan 22, 2022 . Retrieved 2022-10-03 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1664751600.0
- ^ "C.2 Encoding Forms in ISO/IEC 10646" (PDF) . The Unicode Standard, version 6.0 . Mountain View, CA: Unicode Consortium . February 2011. p. 573. ISBN 978-1-936213-01-6 . It [UCS-4] is now treated simply as a synonym for UTF-32, and is considered the canonical form for representation of characters in 10646. Wikipedia revision 1377743665, retrieved 2026-11-19 · 1795042800.0
- ^ For UTF-8: Select point to truncate at. If the byte before it is 0-0x7F, or the byte after it is anything other than the continuation bytes 0x80-0xBF, the string can be truncated at that point. Otherwise search up to 3 bytes backwards for such a point and truncate at that. If not found, truncate at the original position. This works even if there are encoding errors in the UTF-8. UTF-16 is trivial and only has to back up one word at most. Wikipedia revision 1377743665, retrieved 2026-11-19 · 1795042800.0
- ^ "👨🦲 Man: Bald Emoji" . Emojipedia . Retrieved 2021-10-12 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1633993200.0
- ^ "HTML Standard" . html.spec.whatwg.org . Retrieved 2024-11-11 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1731279600.0
- ^ a b "FAQ - UTF-8, UTF-16, UTF-32 & BOM" . Unicode . Retrieved 2022-09-04 . Wikipedia revision 1377743665, retrieved 2026-11-19 · 1662246000.0
- ^ a b Goregaokar, Manish (January 14, 2017). "Let's Stop Ascribing Meaning to Code Points" . In Pursuit of Laziness . Retrieved 2020-06-14 . Folks start implying that code points mean something, and that O(1) indexing or slicing at code point boundaries is a useful operation. Wikipedia revision 1377743665, retrieved 2026-11-19 · 1592089200.0
Cite this
"UTF-32". 1790802121. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1377743665 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy