ASCII code table of Chinese Characters

Source: Internet
Author: User

Each Chinese Character of gb2312 and GBK consists of two bytes. the ASCII values of these two bytes are:
Gb2312:

High8 = 0xa1 --> 0xfe (161-254)
Low8 = 0xa1 --> 0xfe (161-254)

GBK:

High8 = 0x80 --> 0xfe (128-254)
Low8 = 0x40 --> 0xfe (64-254)

 

Difference between gb2312 and GBK: http://zhidao.baidu.com/question/40269499

 

How to print the Chinese ASCII table:

// Print the ASCII Chinese character encoding table <br/> for (INT I = 129; I <256; ++ I) // 129 = 0x81 <br/>{< br/> for (Int J = 64; j <256; ++ J) // 64 = 0x40 <br/>{< br/> char pchar [3]; <br/> pchar [0] = I; <br/> pchar [1] = J; <br/> pchar [2] = '/0 '; <br/> cout <pchar <"" <I <"," <j <"; <br/>}< br/>}

Know a Chinese character and output its ASCII code:

// Obtain the ASCII code of a Chinese character. <br/> char * pchar = "medium"; <br/> // convert each character of pchar to unsigned char, <br/> // use int I = pchar [0] directly to obtain a negative value <br/> unsigned char CI = pchar [0]; <br/> int I = CI; <br/> unsigned char Cj = pchar [1]; <br/> Int J = CJ; <br/> cout <pchar <"" <I <"," <j <Endl; <br/> // output 214,208

Know the ASCII code of Chinese characters and output Chinese characters:

 

// Output Chinese characters whose ASCII code is known <br/> char pchar [3]; <br/> pchar [0] = 214; <br/> pchar [1] = 208; <br/> pchar [2] = '/0'; <br/> cout <pchar <Endl;

Application: removes characters except Chinese characters, letters, and numbers in a file:

 

// Remove characters except Chinese characters, letters, and numbers in the file <br/> // the file must be ANSI encoded <br/> cstring sfile = readlocalfile (sname ); <br/> char * ptemp = sfile. getbuffer (); <br/> cstring stowrite = ""; <br/> for (INT I = 0; I <strlen (ptemp); ++ I) <br/>{< br/> int CH = ptemp [I]; <br/> If (CH <0) <br/>{< br/> // you can use unsigned char to read a value between 128 and 255. <br/> unsigned char c = ptemp [I]; <br/> int itemp = C; <br/> // The value range is 170-254 to remove Chinese Punctuation Marks and other characters, for the range, see the Chinese ASCII table <br/> If (itemp> = 170 & itemp <= 254) <br/>{< br/> char * pchar = new char [3]; <br/> pchar [2] = '/0 '; <br/> pchar [0] = ptemp [I]; <br/> pchar [1] = ptemp [I + 1]; <br/> // cout <pchar; <br/> stowrite + = pchar; <br/> Delete [] pchar; <br/>}< br/> // at this time (CH <0) Two char represents one Chinese character, so the second char is skipped <br/> ++ I; <br/>}< br/> else if (CH >=97 & Ch <= 122) | (CH >=48 & Ch <= 57 )) <br/> {<br/> // cout <ptemp [I]; <br/> stowrite + = ptemp [I]; <br/>}< br/> writelocalfile (stowrite, rname );

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.