[英]Character encoding in programming with languages such as C
Having read tutorials and books on C, I am trying hard to connect my knowledge of UTF (as the text format for roman letters and all sorts of other alphabets/scripts) with C, as a programming language used all over the world. 阅读了有关C的教程和书籍之后,我努力将我对UTF的知识(罗马字母和各种其他字母/脚本的文本格式)与C进行连接,C作为一种在世界范围内使用的编程语言。
C seems to take ASCII characters. C似乎采用ASCII字符。
So if I wanted to write a program with input/output in Chinese,say, how would I implement this with C? 因此,如果我想用中文编写一个带有输入/输出的程序,那我怎么用C来实现呢?
You would be using "wide char" wchar
instead of char
. 您将使用“ wide char”
wchar
而不是char
。
http://en.wikipedia.org/wiki/Wide_character http://en.wikipedia.org/wiki/Wide_character
http://pubs.opengroup.org/onlinepubs/007908799/xsh/wchar.h.html http://pubs.opengroup.org/onlinepubs/007908799/xsh/wchar.h.html
http://msdn.microsoft.com/en-us/library/aa242983(v=vs.60).aspx http://msdn.microsoft.com/zh-CN/library/aa242983(v=vs.60).aspx
There are also specialized libraries like iconv that help on some platforms. 还有一些像iconv这样的专业库,在某些平台上有帮助。
It's character encoding , not text formatting . 它是字符编码 ,而不是文本格式 。 If you want to use UTF in C, you can use a library to handle it (see eg here for UTF-8 libraries: Light C Unicode Library ).
如果要在C中使用UTF,则可以使用一个库来处理它(例如,对于UTF-8库,请参见此处: Light C Unicode Library )。 If you're writing a GUI program, your GUI library probably has facilities to handle it (GTK, KDE, wxWidgets and Tk all support Unicode).
如果要编写GUI程序,则GUI库可能具有处理它的功能(GTK,KDE,wxWidgets和Tk均支持Unicode)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.