简体   繁体   中英

How to read Chinese characters?

I have got a text file from the server and it contains Chinese characters. How to read these characters?

You need to know the encoding of that file. If it is Unicode, or you can convert it to Unicode, the iPhone will be able to handle it.

If you want to display it on the screen, you need proper fonts, which the iPhone also has.

If you want to understand what it says, you have to learn Chinese (or run it through a translator).

Hopefully, the server (if it's using HTTP) sends the encoding in the HTTP headers. Something like:

Content-type: text/plain; charset=UTF-8

Based on this encoding, you can read the text file in and display it properly.

你好MD. 你会说中文吗?

You may want to take a look at CFStringConvertEncodingToNSStringEncoding and kCFStringEncodingBig5_E .

If you get it into the standard system encoding for NSString (I don't think you'll need to ever refer to UTF specifically) then anything that uses an NSString should work.

True that you might need to change the font to a different one, but the standard unicode system font should have chinese glyphs. They might be simiplified vs traditional though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM