Skip to content

Commit b05b70f

Browse files
committed
Add TOC
1 parent 1f8339b commit b05b70f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tutorial04/tutorial04.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
本文是[《从零开始的 JSON 库教程》](https://zhuanlan.zhihu.com/json-tutorial)的第四个单元。代码位于 [json-tutorial/tutorial04](https://github.com/miloyip/json-tutorial/blob/master/tutorial04_answer)
77

8+
本单元内容:
9+
10+
1. [Unicode](#1-unicode)
11+
2. [2.需求](#2-需求)
12+
3. [3. UTF-8 编码](#3-utf-8-编码)
13+
4. [4. 实现 `\uXXXX` 解析](#4-实现-uxxxx-解析)
14+
5. [5. 总结与练习](#5-总结与练习)
15+
816
## 1. Unicode
917

1018
在上一个单元,我们已经能解析「一般」的 JSON 字符串,仅仅没有处理 `\uXXXX` 这种转义序列。为了解析这种序列,我们必须了解有关 Unicode 的基本概念。
@@ -78,7 +86,7 @@ UTF-8 的编码单元是 8 位字节,每个码点编码成 1 至 4 个字节
7886
| U+0800 ~ U+FFFF | 16 | 1110xxxx | 10xxxxxx | 10xxxxxx |
7987
| U+10000 ~ U+10FFFF | 21 | 11110xxx | 10xxxxxx | 10xxxxxx | 10xxxxxx |
8088

81-
这个编码方法的好处之一是,码点范围 U+0000 ~ U+007F 编码为一字节,与 ASCII 编码兼容。这范围的 Unicode 码点也是和 ASCII 的字符相同。因此,一个 ASCII 文本也是一个 UTF-8 文本。
89+
这个编码方法的好处之一是,码点范围 U+0000 ~ U+007F 编码为一个字节,与 ASCII 编码兼容。这范围的 Unicode 码点也是和 ASCII 字符相同的。因此,一个 ASCII 文本也是一个 UTF-8 文本。
8290

8391
我们举一个例子解析多字节的情况,欧元符号 `` → U+20AC:
8492

0 commit comments

Comments
 (0)