Swift字符串比较使用什么样的规范化? [英] What kind of normalization is used by Swift string comparisons?

查看:132
本文介绍了Swift字符串比较使用什么样的规范化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他地方,我看到它告诉 Swift的比较使用NFD规范化。

Elsewhere I've seen it told that Swift's comparisons use NFD normalization.

但是,在iSwift操场中运行,我发现

print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}");

给予 false http://unicode.org/reports/tr15/#Canonical_Equivalence_Figure =nofollow>这是直接来自规范等同标准的示例, Swift的文档声明遵循

gives false, despite this being an example straight from the standard of "Canonical Equivalence", which Swift's documentation claims to follow.

所以,什么样的规范是由Swift执行的,这是一个错误吗?

So, what kind of canonicalization is performed by Swift, and is this a bug?

推荐答案

看起来这是在Swift中的错误,已经修复。使用Swift 3和Xcode 8.0,

It seems that this was in bug in Swift that has since been fixed. With Swift 3 and Xcode 8.0,

print("\u{0071}\u{0307}\u{0323}" == "\u{0071}\u{0323}\u{0307}")

现在打印 true

这篇关于Swift字符串比较使用什么样的规范化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆