Gb2312,gbk,gb18030,utf8 four kinds of Chinese character coding standards What is the difference and contact

Source: Internet
Author: User



From GB2312, GBK to GB18030, these coding methods are backwards compatible, meaning that the same character always has the same encoding in these scenarios, and the latter standard supports more characters. In these codes, English and Chinese can be handled in a unified manner. The method of distinguishing Chinese encoding is that the highest bit of high byte is not 0. According to the programmer, GB2312, GBK, and GB18030 belong to the double-byte character set (DBCS).

Here are the inclusion relationships for these four character sets: GB2312 < GBK < GB18030 < UTF8


-------------------------------------------------------------------------------------------

You can refer to this link http://www.fmddlmyy.cn/text24.html

-------------------------------------------------------------------------------------------

The GB2312 in 1980 included 7,445 characters, including 6,763 Chinese characters and 682 other symbols.

The 1995 Chinese character extension specification GBK1.0 contains 21,886 symbols, including 21,003 Chinese characters and 883 other symbols.

There are two versions of GB18030: gb18030-2000 and gb18030-2005. GB18030-2000 is a replacement version of GBK, and its main feature is the addition of CJK Unified Chinese characters in the GBK basis. The main feature of gb18030-2005 is the addition of CJK Unified Chinese characters to expand B in gb18030-2000 basis.


Otherwise in the processing part of the file, the conversion encoding conversion, there will be a situation that can not be turned, will be error.

In Python, for example,

For-L in open (' Abc_gb18030.txt '):    ls = l.rstrip (' \ n '). Decode (' GBK '). "Encode (' the UTF8 '). Split (' \ t ')    print ls
Abc_gb18030.txt is GB18030 coding, in the code, first turned to GBK, and then turned into a UTF8, because in the transition to GBK, is another large character set to the small character set, so it will error.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Gb2312,gbk,gb18030,utf8 four kinds of Chinese character coding standards What is the difference and contact

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.