从plist读取时,表情符号iCons无法正确显示 [英] Emoji iCons are not displaying correctly when read from plist

查看:78
本文介绍了从plist读取时,表情符号iCons无法正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从plist文件中读取一些文本,并在警报框中将其显示给用户.

I am trying to read some text from a plist file and display it to the users in alert box.

当我使用此代码构建字符串时,一切正常(用户看到带有一个笑脸图标的Hello):

When I build the string using this code, everything works (users sees Hello with a smily icon):

NSString *hello = @"Hello \ue415";

但是当我从plist获取字符串时,使用此代码,使用的是"Hello \ ue415":

but when I get the string from plist, using this code, uses sees "Hello \ue415":

NString *hello =  (NSString *)[pageLiteratureDic objectForKey:litratureKey];

我必须对字符串进行不同的编码吗?任何帮助或指示将不胜感激...每个人都喜欢表情符号;)

Do I have to encode string differently? Any help or pointers will be much appreciated... everyone love emojis ;)

推荐答案

您不应该在plist文件中直接输入"\ ue415"作为文本.\ u ....是C语言中字符串和字符的语法中的转义序列.字符串本身不包含反斜杠和"u"等,它仅包含1个字符,即在代码点0xe415处的Unicode字符.如果要将其保存在plist中,则必须自己在其中手动键入该Unicode字符,并确保使用plist所需的任何编码(可能是utf-8或utf-16,不确定).或者,您可以编写一个程序从该字符串创建一个plist,然后将该plist文件中的内容复制并粘贴到您的文件中.

You shouldn't literally type "\ue415" as text into the plist file. \u.... is an escape sequence in the syntax of strings and characters in the C language. The string itself does not contain backslash and "u" and whatever, it contains just 1 character, the Unicode character at the codepoint 0xe415. If you want to save that in a plist, you have to manually type that one Unicode character in there yourself, making sure to use whatever encoding that is required of a plist (maybe utf-8 or utf-16, not sure). Alternately, you can write a program that creates a plist from that string, and then copy and paste whatever is in that plist file over to your file.

这篇关于从plist读取时,表情符号iCons无法正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆