开发者

Displaying accents and other UTF-8 characters in a UILabel

I have a little app which lists the names of certain people from around the world, and some of those names use characters that are not normal ASCII characters, like DÌaz, or ThÈrËse for example.

The strings show up in Xcode just fine, but when I put them in a UILabel, they behave unexpectedly.

My question is: Is there a way to set up a UILabel to to take the exact string in Xco开发者_开发百科de, and display it properly, even if it is a UTF-8 character (or any other character encoding for that matter)?


UIKit fully supports unicode, your problem is most likely the encoding of the source file. You can set that in the inspector (Xcode 4: ⌘⌥1) under "Text Settings". Make sure it is UTF-8 as well.

Alternative: Use unicode escapes like @"\u2605" (should display ★).


Try to encode the String:

NSString *s = [NSString stringWithCString:value encoding:NSASCIIStringEncoding];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜