Skip to content

Commit

Permalink
Update ch03.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MeouSker77 authored Jul 23, 2023
1 parent c7de396 commit 01865e4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions md/ch03.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,19 +368,19 @@ Rust的字符类型`char`代表一个单独的Unicode字符,是一个32位的

Rust使用`char`表示单个字符,但使用UTF-8编码字符串和文本流。因此,`String`表示它的文本是一个UTF-8字节序列,而不是字符的数组。

字符串字面量是被单括号包围的单个字符,例如`'8'``'!'`。你可以使用Unicode范围内的任何字符:`'錆'`是一个`char`字面量代表日语汉字中的 *sabi* (rust)。[^1]
字符字面量是被单括号包围的单个字符,例如`'8'``'!'`。你可以使用Unicode范围内的任何字符:`'錆'`是一个`char`字面量代表日语汉字中的 *sabi* (rust)。[^1]

[^1]:译者注:看起来这个字符可能无法正常显示,可以在源码里看到这个字符原本的样子。

和字节字面量一样,一些字符需要反斜杠转义(”表3-10”)。

| **字符** | **Rust字符字面量** |
| --- | --- |
| 单引号,`'` | `b'\''` |
| 反斜杠,`\` | `b'\\'` |
| 换行 | `b'\n'` |
| 回车 | `b'\r'` |
| 制表符 | `b'\t'` |
| 单引号,`'` | `'\''` |
| 反斜杠,`\` | `'\\'` |
| 换行 | `'\n'` |
| 回车 | `'\r'` |
| 制表符 | `'\t'` |

如果你喜欢的话,你可以以十六进制的方式写出一个字符的Unicode编码:

Expand Down

0 comments on commit 01865e4

Please sign in to comment.