Swift 字符串比较使用哪种规范化?
What kind of normalization is used by Swift string comparisons?
Elsewhere I've seen it told Swift 的比较使用 NFD 归一化。
但是,running in the iSwift playground我发现
print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}");
给出 false
,尽管 this being an example straight from the standard of "Canonical Equivalence", which Swift's documentation claims to follow.
那么, 由 Swift 执行了什么样的规范化,这是一个错误吗?
这似乎是 Swift 中的错误,此错误已被修复。使用 Swift 3 和 Xcode 8.0,
print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}")
现在打印 true
.
Elsewhere I've seen it told Swift 的比较使用 NFD 归一化。
但是,running in the iSwift playground我发现
print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}");
给出 false
,尽管 this being an example straight from the standard of "Canonical Equivalence", which Swift's documentation claims to follow.
那么, 由 Swift 执行了什么样的规范化,这是一个错误吗?
这似乎是 Swift 中的错误,此错误已被修复。使用 Swift 3 和 Xcode 8.0,
print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}")
现在打印 true
.