iphone - 显示编码字符,如 å,ä,ö在UI标签中
我有一个列表,其每一行都使用 UILabel。如果我尝试显示特殊字符,例如 å,ä,ö,它会将它们显示为 å ä ö 如何将它们转换为 UTF8 编码的 NSString?
I have a list that uses UILabel for each of its rows. If I try to display special characters such as å,ä,ö, it displays them as å ä ö How do I convert them into a UTF8 encoded NSString?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些字符在 WebView 中正确显示,因为它正确解释了 HTML 实体。
也许这个方便的 NSString 类别可以帮助您在 UILabel 中显示所需的文本:
https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m
同时导入 NSString+HTML.h 和 NSString+HTML.m 文件,然后在你的课堂上使用
,然后你可以使用
编辑:
你也可以尝试HerbertHansen 在苹果开发板上的解决方案,不需要整个库
The characters display correctly in a WebView because the HTML entities are correctly interpreted by it.
Maybe this handy NSString category can help you to display the text how you want in a UILabel:
https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m
Import both NSString+HTML.h and NSString+HTML.m files, then in your class use
and then you can use
EDIT :
You can also try HerbertHansen's solution on the apple dev boards which doesn't need a whole library