Apple 提供了使用数据库中存储的规范化文本版本在数据库中创建附加列的示例: DerivedProperty
函数 normalizeString 包含代码:
NSMutableString *result = [NSMutableString stringWithString:unprocessedValue];
CFStringNormalize((CFMutableStringRef)result, kCFStringNormalizationFormD);
CFStringFold((CFMutableStringRef)result, kCFCompareCaseInsensitive | kCFCompareDiacriticInsensitive | kCFCompareWidthInsensitive, NULL);
我已经测试了这个方法,并且有一个将文本转换为规范化版本的例子:
ąĄćłŁÓŻźŃĘęĆ
-> aacłłozzneec
除了以下字符外,所有变音符号都已正确更改:łŁ
是否有任何其他选项可以进行适当的规范化?
最佳答案
我不会说波兰语,所以我的回答可能非常错误,但根据 http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt字符“ł”和“Ł”不是 “普通”字符与变音符号的组合。
Unicode 数据文件中“±”的条目是
0105;LATIN SMALL LETTER A WITH OGONEK;Ll;0;L;0061 0328;;;;N;LATIN SMALL LETTER A OGONEK;;0104;;0104
and the sixth field "0061 0328" shows that "ą" can be decomposed into "a" and U+0328 (COMBINING OGONEK).
But the entries for "ł" and "Ł" are
0141;LATIN CAPITAL LETTER L WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER L SLASH;;;0142; 0142;LATIN SMALL LETTER L WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER L SLASH;;0141;;0141
where the sixth field is empty, so these characters do not have a decomposition.
Therefore I doubt that there will be any function that normalizes "ł" into "l", and you would have to do that using
[result replaceOccurrencesOfString:@"ł" withString:@"l" options:0 range:NSMakeRange(0, [result length])];
关于objective-c - 在 sqlite 中制作规范化版本的字符串 - 波兰字符 ł,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16187077/