编码单元

Encoding & Standards

用于编码字符的最小位组合:UTF-8为8位,UTF-16为16位,UTF-32为32位。

A code unit is the fundamental building block of a Unicode encoding form. It's important to distinguish code units from code points — a single code point may require multiple code units depending on the encoding.

In UTF-8, a code unit is 8 bits (1 byte). The emoji 😀 requires 4 code units. In UTF-16, a code unit is 16 bits (2 bytes). The same emoji requires 2 code units (a surrogate pair). In UTF-32, it's 1 code unit (4 bytes).

Many programming language string APIs operate on code units rather than code points, which is why string length calculations can be confusing with emoji.

相关术语

UTF-16 UTF-16
每字符使用2或4个字节的可变长度Unicode编码方式,被JavaScript、Java和Windows内部使用。
UTF-32 UTF-32
每字符固定使用4个字节的Unicode编码方式,可直接映射到码位,但存储效率较低。
UTF-8 UTF-8
每字符使用1至4个字节的可变长度Unicode编码方式,是互联网上最主流的编码,被98%以上的网站采用。
代理对 代理对
用于表示U+FFFF以上字符的两个UTF-16编码单元组合,由高代理(U+D800-U+DBFF)和低代理(U+DC00-U+DFFF)构成。

相关工具

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