不同的 unicode 表示无法从 NSDictionary 获取
我正在使用 MacFUSE 编写一个文件系统,来存储我使用字典的目录和文件的内容/属性,因为它们的路径是唯一的。对于正常路径来说,没有任何问题,但是包含“非标准”字母(如“åäö”)的路径无法正常工作。我已将其范围缩小到 unicode 格式。
用@“ä”分配一个字符串给出unicode 228,但有时(不是所有时候)我的代码是从MacFUSE调用的,“ä”表示为两个unicode字符:“a”(unicode:97)后跟“¡ “(统一码:776)。这会导致 [dictionary objectForKey:path] 返回 nil。 NSLog 使用“ä”正确打印路径,但 [string isEqualToString:] 返回 NO。
有什么好的方法可以解决这个问题吗?或者我是否必须搜索并修复每条路径?
I'm writing a file system using MacFUSE, to store content/attributes of directories and files i use dictionaries, since their path is unique. For normal paths there's no problem what so ever, but paths containing "non-standard" letters like "åäö" is not working properly. I've narrowed it down to the unicode format.
Allocating a string with @"ä" gives the unicode 228, but sometimes (not all the times) my code is called from MacFUSE with the "ä" represented as two unicode characters: "a" (unicode:97) followed by "¨" (unicode:776). This causes [dictionary objectForKey:path] to return nil. NSLog prints the path correctly with "ä", but [string isEqualToString:] returns NO.
Is there any good way to fix this? Or would i have to search through and fix every path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在使用字符串之前调用
-precomposedStringWithCanonicalMapping
。Call
-precomposedStringWithCanonicalMapping
on your string before using it.