Displaying Chinese Unicode

Hey guys. I am wondering a couple of things:

1. Does the iphone support displaying both simplified Chinese and traditional Chinese?
2. How do I display chinese characters? I know they can both be encoded in Unicode, so do I just provide the unicode string on the screen then the phone will be able to decode it when they have the right drivers installed?

Thanks,
Vic

Macbook, Mac OS X (10.5.6)

Posted on Feb 8, 2009 1:38 PM

Reply
7 replies

Feb 9, 2009 1:32 AM in response to heromyst

I haven't yet attempted to localize my iPhone apps for China, but maybe I can help based on other I18N work. The character codes for Traditional and Simplified Chinese will differ only when ANSI code pages (950 and 936) are used. For a Unicode-only platform like the iPhone, there's only one code point for each character. No matter how many languages share a particular character, it will be found at only one code point in Unicode.

Of course there's still a question about which font to use. For example Japanese shares a number of code points with both Traditional and Simplified Chinese, but it's my understanding that the way these are drawn by a Unicode font is unacceptable to many Japanese customers. It's probably unwise to use the same font for both Chinese and Japanese even if it covers all the necessary code points. But I think this is an iPhone system decision. I would expect an appropriate default font family to be switched in when the user selects a language from the Settings panel.

So I would answer yes to both questions 1 and 2, but hope you'll also hear from someone who's actually localized their app for China.

Feb 9, 2009 5:41 AM in response to RayNewbie

For example Japanese shares a number of code points with both Traditional and Simplified Chinese, but it's my understanding that the way these are drawn by a Unicode font is unacceptable to many Japanese customers.


Normally people use Unicode fonts that are tailored to the language. For example in OS X proper, if you are using Japanese, you will make sure Japanese is higher than Chinese in system prefs/international/languages, and then Unicode codepoints will use the Hiragino font instead of a Chinese one.

Feb 15, 2009 2:29 AM in response to heromyst

Ok I kind of found something and it works.

UniChar chars[] = {0x4E00}; // 1 in chinese
NSString *string = [[NSString alloc] initWithCharacters:chars
length:sizeof(chars) / sizeof(UniChar)];

Displaying string will then display the chinese character "1".

So the problem I've run into is:

1. Say I want a sentence of chinese characters. Is there an easy way to convert from chinese characters to hex? Or from chinese characters to unicode to hex?
2. There doesn't seem to be an elegant way for me to pass the chinese sentence into a database field other than throwing a serialized string in there with delimiters dividing the different characters of the sentence.

If anyone has any elegant solutions, I would be really grateful to hear it. At least I can display chinese characters now 🙂, but the problem is being able to store and decode them elegantly. I still haven't figured out to decode them outside of decoding the HEX value. If there is a way to decode their unicode, that would be best.

Thanks,
Vic

Feb 15, 2009 5:14 PM in response to heromyst

I'm not clear on what you mean by "convert Chinese characters to Unicode or hex" or vice-versa. Where are these characters coming from?

Are you asking how to scan a printed document into a text file? I have no experience with that but a search on Chinese OCR will get you started.

Are you asking how to key Chinese characters into a text file? I don't have any experience with that either, but I think all OS X platforms support this, and any native Chinese speaker who owns a Mac should be able to help you.

Are you asking how to convert a Unicode text file (e.g. UTF-16) into the correct glyphs on your display? Since you like the font you saw when you displayed the numeral one, that problem is already solved. I.e., the code for reading and displaying a UTF-16 file of Chinese text is identical to the code for reading and displaying a UTF-16 file of English text. The conversion from code points to glyphs is done by the font.

Similarly, if you know how to get Unicode English in and out of a database, you would use the same code for Chinese. The database doesn't know or care whether the Unicode strings are English or Chinese.

Mar 19, 2009 2:12 PM in response to iphonedevD

The original question in this thread was very basic, so I felt I could help. But I've only worked with Chinese on Win32 systems, not on OS/X or the iPhone.

From your description the first things I would look at are the font family and the char code conversion. So here are some basic questions to start with:

_Isolating a font problem_:
1) Is the html Simplified or Traditional Chinese?
2) Are the same chars showing the same errors on both the Simulator and the iPhone?
3) If the chars aren't right on the Simulator, try setting UITextView to a font capable of SC or TC.
4) If the chars aren't right on the device:
a) Have you tried switching it to Chinese in Settings->General? I know you have, but just to be complete...
b) Check the installed fonts on your device. FontViewer is a free app that will do this for you. Find out which of these fonts supports Chinese and try setting your UITextView to one or more of them. My OS 2.1 Touch has ArielUnicodeMS, STHeitiSC and STHeitiTC. Test with a language-specific font if you have one.
c) How do the bad chars show up in the device's Safari?

_Isolating a conversion problem_:

1) What is the charset of the html docs? This should be found in the html header and will look something like charset=utf-8;
2) If the charset isn't utf-8, try to find a Chinese doc that is, or convert your docs to utf (some word processors will do this for you), and make sure your NSString encoding is set to match.

Sure hope some of the above helps. If not, I hope someone with more experience will respond.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Displaying Chinese Unicode

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.