gpt4 book ai didi

swift - Swift 中的 Unicode 标量值

转载 作者:搜寻专家 更新时间:2023-11-01 06:37:04 25 4
gpt4 key购买 nike

在 Swift Programming Language 3.0 中,关于字符串和字符的章节,书上说

A Unicode scalar is any Unicode code point in the range U+0000 to U+D7FF inclusive or U+E000 to U+10FFFF inclusive. Unicode scalars do not include the Unicode surrogate pair code points, which are the code points in the range U+D800 to U+DFFF inclusive

这是什么意思?

最佳答案

Unicode 标量 是未序列化为一对 UTF-16 代码单元的代码点。

代码点 是在 Unicode 标准中对字符进行编码后产生的数字。例如,字母 A 的代码点是 0x41(或十进制的 65)。

代码单元 是代码点序列化中使用的每组位。例如,UTF-16 使用一个或两个 16 位的代码单元。

字母 A 是一个 Unicode 标量,因为它只能用一个代码单元表示:0x0041。但是,不太常见的字符需要两个 UTF-16 代码单元。这对代码单元称为代理对。因此,Unicode Scalar 也可以定义为:除了由代理对表示的代码点之外的任何代码点。


courteouselk 的回答是正确的,这只是一个更简单的英文版本。

关于swift - Swift 中的 Unicode 标量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40256248/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com