开发者

iOS, CoreText and Unicode

I was wondering how should I encode a text to be displayed using CoreText. For information, CoreText provides native Unicode support.

But, if I've my source text, for example in a XML file, how should I have to encode it to be prope开发者_StackOverflowrly rendered?

<node>Text with Unicode àccented charactèrs would cause XML formatting errors!</node>

I was also thinking using NSString+HTML that provides method like this (don't remember the exact method name, it's just a sample):

[string stringByDecodingHtmlEntities]

So what would you suggest?

Thanks, Simone.


You should use UTF-8. As this is the default encoding on Max OS X and iOS, as well for XML, this should just work, as Joachim said.

If you want to be really sure, make sure that your editor is configured to write UTF-8, and specify the encoding in an XML declaration at the beginning of the XML file:

<?xml version="1.0" encoding="UTF-8"?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜