开发者

iOS, CoreText and Unicode

开发者 https://www.devze.com 2023-02-13 04:33 出处:网络
I was wondering how should I encode a text to be displayed using CoreText. For information, CoreText provides native Unicode support.

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

精彩评论

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