The interchange technology of GB Code and BIG5 code
Chinese and English are different in ASCII code, which uses two bytes to represent it. In fact, the text file is saved in the corresponding two bytes per Chinese character encoding, and the display problem is automatically resolved by the Chinese operating system.
Encoding is not uniform, we use GB code, and Taiwan is using BIG5 code. The BIG5 code file holds the corresponding BIG5 encoding of Chinese characters, and the GB code file holds the corresponding GB code. So the key to the conversion work is to have a file that records each BIG5 encoding corresponding to the GB encoded Code table.
GB Code encoding rule is this: each Chinese character is composed of two bytes, the first byte range from 0xa1-0xfe, a total of 96 kinds. The second byte range is 0xa1-0xfe, a total of 96 species. The two bytes can be used to define a total of 96 * 96=8836 characters. There are actually 6,763 characters in total.
BIG5 code Coding rules are: Each Chinese character is composed of two bytes, the first byte range from 0x81-0xfe, a total of 126 kinds. The second byte range is 0x40-0x7e,0xa1-0xfe, a total of 157 species. In other words, the two bytes can be used to define a total of 126 * 157=19782 characters. These characters are part of our commonly used, such as, ding, these words we call common characters, its BIG5 code range of 0xa440-0xc671, a total of 5,401. Less commonly used words, such as abuse, modulation, we call the second word, the range of 0XC940-0XF9FE, a total of 7,652, the rest is some special characters.
The principle of making a Code table file is this: first write all the GB encoding into a file, and then, with GB code to BIG5 code conversion function software, such as Ucdos under the CONVERT.EXE, the file converted to BIG5 code file, that is, the Code table file.
The following program can write all GB codes to file Gb.txt (all of the following programs are written in FoxPro and can be easily converted to other languages)
fp = fopen ("Gb.txt", 2)
For i=161 to 247
For j=161 to 254
=fwrite (FP,CHR (i) +CHR (j))
Next
=fwrite (FP,CHR) +CHR (10))
Next
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.