UTF-32

Encoding & Standards

Eine Unicode-Kodierung fester Breite, die genau 4 Bytes pro Zeichen verwendet und eine direkte Codepoint-Zuordnung auf Kosten des Speicherplatzes ermöglicht.

UTF-32 is the simplest Unicode encoding: every character uses exactly 4 bytes, and the value directly corresponds to the code point. This makes random access and character counting trivial.

However, UTF-32 uses 4x the memory of ASCII text and 2x that of UTF-16 for most common characters. It's rarely used for storage or transmission but can be convenient for internal string processing.

Python 3's internal string representation uses a variable-width encoding (Latin-1, UCS-2, or UCS-4) depending on the highest code point in the string, which is why `len('😀')` correctly returns 1.

Verwandte Werkzeuge