开发者

Showing asian unicode string in UILabel

How can we show asian unicode values in UILabel

\U2013\U00ee\U2013\U00e6\U2013\U2202\U2013\U220f\U2013\U03c0 \U2013\U00ee\U2013\U220f\U2013\U03c0\U2013\U00aa\U2013\U221e\U2014\U00开发者_JAVA技巧c5

Thanks


I'm not sure what is particularly “Asian” about that text,

  • U+2013 is an en-dash (–)
  • U+00ee is a lowercase ‘i’ with a circumflex (î)
  • U+00e6 is the old ligature for ae (æ)
  • U+2202 is the character for a partial differential (∂).

If your program is being localised [that is to say that the program will be available in more than one language], you should put your text in a Localizable.strings file. When you create one of these files in Xcode, it will automatically be saved in a suitable encoding (most likely UTF16), and it will be included in your built software. The file has the following format:

 "Base language text" = "Translation text";
 "Good evening!" = "こんばんは";

You can reference the translations using:

NSString *goodEvening = NSLocalizedString (@"Good evening!", @"An interjection said during the latter part of the day.");

This function will automatically translate the string into any available localisations that your software has (by searching for an appropriate Localizable.strings file), based on the user's chosen regional settings on their iPhone or Mac. If no suitable translation is found, it will return the original base language string. The second argument to NSLocalizedString is provided to give context or meaning to the translation, it does not get included in your software.

If you simply want to display text, you can include Unicode code points in NSString constants, but you must use a lowercase u (unless they are 32-bit code points):

NSString *myPunctuation = @"\u2013\u00ee"; // lowercase u
NSLog (@"%@", myPunctuation);

...

myPunctuation = @"\U00002013\U000000ee";  // uppercase U
NSLog (@"%@", myPunctuation);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜