简体   繁体   English

如何阅读汉字?

[英]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. 如果它是Unicode,或者您可以将其转换为Unicode,则iPhone将能够处理它。

If you want to display it on the screen, you need proper fonts, which the iPhone also has. 如果要在屏幕上显示它,则需要iPhone也具有的正确字体。

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. 希望服务器(如果使用的是HTTP)在HTTP标头中发送编码。 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. 你好MD。 你会说中文吗? 你会说中文吗?

You may want to take a look at CFStringConvertEncodingToNSStringEncoding and kCFStringEncodingBig5_E . 您可能想看看CFStringConvertEncodingToNSStringEncodingkCFStringEncodingBig5_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. 如果将其纳入NSString的标准系统编码中(我认为您不需要专门参考UTF),那么使用NSString的任何东西都应该起作用。

True that you might need to change the font to a different one, but the standard unicode system font should have chinese glyphs. 没错,您可能需要将字体更改为其他字体,但是标准unicode系统字体应带有中文字形。 They might be simiplified vs traditional though. 他们可能比传统的要简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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