UTF-32: When Fixed-Width Character Encoding Makes Sense
UTF-32 encodes every Unicode character in exactly 4 bytes — no variable-width complexity, no surrogate pairs, no multi-byte sequences. This simplicity comes at a cost: it's the least space-efficient of the Unicode encodings. So when does it make sense?
The Case for Fixed Width
Variable-width encodings like UTF-8 are efficient but make some string operations O(n) instead of O(1). Random access by character index requires scanning from the beginning of the string to count code points. With UTF-32, each character occupies exactly 4 bytes, so jumping to the nth character is a simple multiplication. This matters for text editors and regular expression engines that need fast random access.
Memory Cost
A 100-character ASCII string takes 100 bytes in UTF-8 and 400 bytes in UTF-32. For English text, UTF-32 uses 4× the memory of UTF-8. For CJK text (Chinese, Japanese, Korean), the ratio improves: those characters are 3 bytes in UTF-8 but still 4 in UTF-32. UTF-32 is almost never used for storage or network transmission.
Where UTF-32 Appears
Some Unix-like systems use UTF-32 as their internal wchar_t representation, making it the natural choice for POSIX-compliant wide-character string APIs. Python 3 uses a flexible internal representation that approximates UTF-32 when strings contain characters outside the BMP. Our UTF-32 encoding reference shows the exact byte sequences for any character.
Byte Order in UTF-32
Like UTF-16, UTF-32 has endianness variants: UTF-32 BE and UTF-32 LE. Files should include a Byte Order Mark to identify which variant is in use. Use our byte decoder to inspect and interpret UTF-32 encoded data.