← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 10642 · 生成模型:未记录

char是Unicode标量

理解等级:初级

char 表示一个 Unicode 标量值,占四字节,其范围排除代理码位。它可以包含汉字等超出 ASCII 的标量。显示上一个字符可能由多个标量组合,按 char 计数的结果因此可能与界面预期不同。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 常见编程概念 Data Types · 查看原书依据

      Note that we specify char literals with single quotes, as opposed to string literals, which use double quotes. Rust’s char type is four bytes in size and represents a Unicode scalar value, which means it can represent a lot more than just ASCII. Accented letters; Chinese, Japanese, and Korean characters; emoji; and zero-width spaces are all valid char values in Rust.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第03章 常见编程概念(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c03.xhtml`,块 0108) - 结论依据:书中说明 char 的存储大小与 Unicode 标量值范围。 - 原始内容:Note that we specify char literals with single quotes, as opposed to string literals, which use double quotes. Rust’s char type is four bytes in size and represents a Unicode scalar value, which means it can represent a lot more than just ASCII. Accented letters; Chinese, Japanese, and Korean characters; emoji; and zero-width spaces are all valid char values in Rust.