UTF-32

Encoding & Standards

每字符固定使用4个字节的Unicode编码方式,可直接映射到码位,但存储效率较低。

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.

相关术语

BOM(字节顺序标记) (BOM) BOM(字节顺序标记) (BOM)
放置在文本文件开头的字符(U+FEFF),用于指示UTF-16/UTF-32编码中的字节顺序(字节序)。
UTF-16 UTF-16
每字符使用2或4个字节的可变长度Unicode编码方式,被JavaScript、Java和Windows内部使用。
UTF-8 UTF-8
每字符使用1至4个字节的可变长度Unicode编码方式,是互联网上最主流的编码,被98%以上的网站采用。
编码单元 编码单元
用于编码字符的最小位组合:UTF-8为8位,UTF-16为16位,UTF-32为32位。

相关工具

🔢 Unicode 查询 Unicode 查询
输入 U+1F600 等码位,获取表情符号、编码详情、UTF-8/16 字节和 HTML 实体。