# 字符（计算）

在计算领域，字符是书写文本的抽象单位，例如字母、数字、标点符号或符号，计算机在内部用数字表示它。字符到数字的映射是每一种字符编码的核心：*编码字符集*为其字符库中的每个字符分配一个唯一的数字，称为码点；而*编码*则规定如何将这些码点转换为字节以便存储和传输<sup>[1](http://www.unicode.org/reports/tr17/)</sup><sup> • </sup><sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 抽象字符是书写文本的单位；在编码字符集中被分配数字后，就成为编码字符<sup>[3](https://unicode.org/versions/Unicode18.0.0/core-spec/chapter-2/)</sup> |
| Unicode码空间 | 十六进制0至10FFFF的整数，共1,114,112（17 × 2<sup>16</sup>）个码点<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup> |
| 已分配字符 | 截至Unicode 16.0（2024年）约155,000个；Unicode 17.0（2025年）为159,801个；Unicode 18.0（2026年）为172,808个<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup><sup> • </sup><sup>[5](https://www.unicode.org/versions/Unicode17.0.0/)</sup><sup> • </sup><sup>[6](https://www.unicode.org/versions/Unicode18.0.0/)</sup> |
| 编码形式 | UTF-8每个字符使用1至4字节，UTF-16使用1或2个16位码元，UTF-32每个字符使用4字节<sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup> |
| 示例 | 字母á在Unicode中的码点为225（0xE1），但在UTF-8中占两个字节<sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup> |
| 有问题的码点 | 2,048个代理项码点（U+D800至U+DFFF）、非字符以及遗留控制码无法有效出现在交换文本中<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup> |
| 交换默认编码 | UTF-8是WHATWG编码标准对Web所要求的编码，IETF政策（BCP 18）要求协议能够使用它<sup>[7](https://encoding.spec.whatwg.org/)</sup><sup> • </sup><sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup> |

## 字符、码点与码元

Unicode字符编码模型（Unicode技术报告第17号）将这一过程的各个层次区分开来。首先选定一个抽象字符库；然后为每个字符分配一个整数，即其码点；接着由编码形式将码点表示为固定宽度的*码元*序列，例如8位字节或16位字；最后由编码方案将这些码元序列化为字节，包括字节序处理<sup>[1](http://www.unicode.org/reports/tr17/)</sup>。编码字符集也称为字符编码、编码字符库、字符集定义或代码页<sup>[1](http://www.unicode.org/reports/tr17/)</sup>。

在Unicode标准中，码空间由0至10FFFF<sub>16</sub>的整数构成，码点即该范围内的任意值。当抽象字符被分配到某个特定码点时，就称为编码字符<sup>[3](https://unicode.org/versions/Unicode18.0.0/core-spec/chapter-2/)</sup>。码点与字节之间的映射并非一一对应：á的码点在十进制中始终是225，但UTF-8将其存储为两个字节，同一个字符在UTF-8、UTF-16和UTF-32中可占用不同数量的字节<sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup>。

## 字符不一定对应单个码点

单个抽象字符可能由码点序列表示。带尖音符的拉丁大写字母G既可以写成预组合码点，也可以写成U+0047 拉丁大写字母G后接U+0301 组合尖音符的序列<sup>[8](https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/)</sup>。*组合字符序列*通常是一个基字符后接一个或多个组合字符，它是*文本元素*的一种；文本元素是某种过程视为一个单位的任意字符序列的统称<sup>[9](https://www.unicode.org/faq/char_combmark.html?source=post_page---------------------------)</sup>。

对最终用户而言，相关单位是字素：特定书写系统中最小区别性的书写单位。字母å在丹麦语中是一个字素，无论编码为预组合形式还是A加组合圆环；[天城文](https://www.edgepedia.org/zh/devanagari)音节क्तु虽然是四码点序列，却是一个字素<sup>[9](https://www.unicode.org/faq/char_combmark.html?source=post_page---------------------------)</sup>。Unicode标准附件第29号定义了*字素簇*，即对用户感知字符的近似，并给出用于光标移动、文本选择、删除和字符位置计数的默认算法<sup>[10](http://www.unicode.org/reports/tr29/)</sup>。W3C指出了这种近似的局限：在Unicode 15.1之前，默认规则将孟加拉语正字法音节kshī拆分为两个字素簇，因此处理此类文字的应用需要针对特定文字进行定制<sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup>。

## 编码形式

Unicode定义了三种编码形式。UTF-8是一种可变长度形式，对ASCII字符使用一个字节，对若干其他字母文字区块使用两个字节，对基本多文种平面的其余部分使用三个字节，对增补字符使用四个字节。UTF-16对BMP字符使用两个字节，对增补字符使用四个字节（作为代理对）。UTF-32对每个字符使用四个字节<sup>[2](https://www.w3.org/International/articles/definitions-characters/index.en)</sup>。UTF-8的设计初衷是便于与现有基于ASCII的系统配合使用<sup>[11](https://www.unicode.org/versions/latest/ch01.pdf)</sup>，WHATWG编码标准要求新协议和格式使用它，称其为Unicode交换最合适的编码<sup>[7](https://encoding.spec.whatwg.org/)</sup>。

## 历史

早期计算机使用小型且互不兼容的编码存储文本。ASCII及其扩展局限于256个字符，而在Unicode之前，有数百种不同的系统为字符分配数字；两种编码可能用同一个数字表示不同字符，或用不同数字表示同一字符，因此系统之间传递的数据有损坏的风险<sup>[12](https://www.unicode.org/versions/Unicode1.0.0/ch01.pdf)</sup><sup> • </sup><sup>[13](https://unicode.org/standard/WhatIsUnicode.html)</sup>。

Unicode项目始于1987年末，源于施乐公司的乔·贝克尔（Joe Becker）与苹果公司的李·柯林斯（Lee Collins）和马克·戴维斯（Mark Davis）之间的讨论。到1988年初，他们已完成对固定宽度与混合宽度文本访问、双字节文本存储需求以及世界各字母文字初步字符计数的调查，并由此推导出基本架构。这个名称由贝克尔最迟于1987年12月提出，反映了三个目标：通用、统一、唯一的编码<sup>[14](https://www.unicode.org/history/summary.html)</sup>。Unicode联盟于1991年1月在加利福尼亚州注册成立，标准1.0.0版于1991年10月发布<sup>[15](https://www.unicode.org/history/?level=1)</sup><sup> • </sup><sup>[16](https://www.unicode.org/history/publicationdates.html)</sup>。

最初的设计是面向60,000多个图形字符的固定宽度16位编码<sup>[14](https://www.unicode.org/history/summary.html)</sup>。此后它远远超出了16位：码空间现在跨越17个平面，每个平面65,536个码点，该标准与国际标准ISO/IEC 10646逐码相同，并通过1991年和1992年的谈判与之合并<sup>[11](https://www.unicode.org/versions/latest/ch01.pdf)</sup><sup> • </sup><sup>[17](https://www.unicode.org/versions/Unicode1.1.0/)</sup>。

## 有问题的码点与子集

码空间中的每个值并非都表示可用文本。RFC 9839是蒂姆·布雷（Tim Bray）和保罗·霍夫曼（Paul Hoffman）提出的IETF拟议标准，它将类型为代理项或非字符的码点以及遗留控制码归类为*有问题*<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup>。U+D800至U+DFFF中的2,048个代理项码点用于在UTF-16中构成代理对；代理项在任何其他编码形式中都没有意义，在UTF-8中表示代理项是被禁止的<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup>。非字符包括U+FDD0至U+FDEF范围以及每个平面的最后两个码点；它们并非为开放交换而设计<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup>。

由于未分配码点会随着新字符的加入而经常被分配，该RFC建议不要制定禁止未分配码点的规范，而是为协议定义了三个具名子集：Unicode标量值（除代理项外的所有码点）、XML字符（额外排除遗留C0控制字符以及非字符U+FFFE和U+FFFF）和Unicode可分配字符（所有不属于有问题类别的码点）<sup>[4](https://www.rfc-editor.org/info/rfc9839/)</sup>。

## 字符库的规模

字符库持续增长。Unicode 17.0于2025年9月9日发布，新增4,803个字符，包括四种新文字和沙特里亚尔符号，总计159,801个<sup>[5](https://www.unicode.org/versions/Unicode17.0.0/)</sup>。Unicode 18.0于2026年9月16日发布，新增13,007个字符，包括原始[楔形文字](https://www.edgepedia.org/zh/cuneiform)（数字）、女真文和篆文，总数达到172,808个<sup>[6](https://www.unicode.org/versions/Unicode18.0.0/)</sup>。世界主要语言中使用的大多数常用字符位于前65,536个码点，即基本多文种平面<sup>[11](https://www.unicode.org/versions/latest/ch01.pdf)</sup>。

## References

1. [Unicode Technical Report #17: Unicode Character Encoding Model, Unicode Consortium](http://www.unicode.org/reports/tr17/)
2. [Character encodings: Essential concepts, W3C Internationalization](https://www.w3.org/International/articles/definitions-characters/index.en)
3. [The Unicode Standard, Version 18.0, Chapter 2: General Structure](https://unicode.org/versions/Unicode18.0.0/core-spec/chapter-2/)
4. [RFC 9839: Unicode Character Repertoire Subsets, RFC Editor](https://www.rfc-editor.org/info/rfc9839/)
5. [Unicode 17.0.0, Unicode Consortium](https://www.unicode.org/versions/Unicode17.0.0/)
6. [Unicode 18.0.0, Unicode Consortium](https://www.unicode.org/versions/Unicode18.0.0/)
7. [Encoding Standard, WHATWG](https://encoding.spec.whatwg.org/)
8. [The Unicode Standard, Version 17.0, Chapter 3: Conformance](https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/)
9. [FAQ: Characters and Combining Marks, Unicode Consortium](https://www.unicode.org/faq/char_combmark.html?source=post_page---------------------------)
10. [UAX #29: Unicode Text Segmentation, Unicode Consortium](http://www.unicode.org/reports/tr29/)
11. [The Unicode Standard, Chapter 1: Introduction](https://www.unicode.org/versions/latest/ch01.pdf)
12. [The Unicode Standard, Version 1.0, Chapter 1: Introduction](https://www.unicode.org/versions/Unicode1.0.0/ch01.pdf)
13. [What is Unicode?, Unicode Consortium](https://unicode.org/standard/WhatIsUnicode.html)
14. [Summary Narrative, Unicode History](https://www.unicode.org/history/summary.html)
15. [History of Unicode, Unicode Consortium](https://www.unicode.org/history/?level=1)
16. [History of Unicode Release and Publication Dates, Unicode Consortium](https://www.unicode.org/history/publicationdates.html)
17. [Unicode 1.1 version page, Unicode Consortium](https://www.unicode.org/versions/Unicode1.1.0/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 25, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 25, 2026*

Topic: 社会与历史 › 语言与语言学 › 文字与符号系统 › Scripts in Unicode and digital encoding

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/character-computing

English original: https://www.edgepedia.org/character-computing
