objective-c - 在 sqlite 中制作规范化版本的字符串 - 波兰字符 ł

标签 objective-c database string sqlite

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/

相关文章:

ios - UISegmentedController 在按同一段两次后卡住

objective-c - 点击文本字段时不显示键盘

objective-c - 如何从网站动态获取数据并将其添加到 iPhone 应用程序?

php - 父行上带有 JOIN ... LIMIT 的 LIMIT 记录不适用于子行

c++ - 字符串文字中的比较导致未指定的行为 - C++

c# - 如何拆分分隔符保留在结果末尾的字符串?

ios - NSNetService 发布,但从未调用过 didAcceptConnectionWithInputStream...

database - 如何解析来自 Google Alerts 的数据?

sql - Postgres 数据库如果不存在则创建

string - 如何在两个字符串中找到最大的子字符串?