Showing asian unicode string in UILabel

你说的曾经没有我的故事 提交于 2019-12-24 06:20:26

问题


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\U00c5

Thanks


回答1:


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);


来源:https://stackoverflow.com/questions/2294390/showing-asian-unicode-string-in-uilabel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!