等特殊字符与常规A进行比较

等特殊字符与常规A进行比较

本文介绍了将À等特殊字符与常规A进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些语言中,有类似À的字母,我看到对于表视图部分,本机iOS将À放在与A相同的部分下.
我想做同样的事情,我通过比较第一个字母来建立我的部分,所以我需要À等于A.
我尝试使用localizedCompare,但仍然没有得到那两个相等的信息.

In some languages there are letters like À, I saw that for table view sections the native iOS put À under the same section as A.
I want to do the same thing, I'm building my sections by comparing the first letter, so I need that À will be equal to A.
I tried using localizedCompare but still I didn't got that those two are equal.

有没有办法进行这种比较?或归一化的À,因此它将是A吗?

Is there a way to to this kind of compare? or to normalised À so it will be A ?

推荐答案

请勿按照其他答案进行转换或变换.首先,尝试-[NSString localizedStandardCompare:].如果那不能满足您的要求,请将选项之间的NSDiacriticInsensitiveSearch传递给NSString比较方法之一(例如-compare:options:range:locale:).您可能还需要使用其他选项,例如NSCaseInsensitiveSearch.

Don't convert or transform as per the other answers. First, try -[NSString localizedStandardCompare:]. If that doesn't do what you want, pass NSDiacriticInsensitiveSearch among the options to one of the NSString comparison methods (such as -compare:options:range:locale:). You may want to use additional options, too, such as NSCaseInsensitiveSearch.

这篇关于将À等特殊字符与常规A进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 11:38