GBK (character encoding)#Encoding

{{Short description|Simplified Chinese character encoding}}

{{More citations needed|date=October 2016}}

{{Infobox character encoding

| name = Guójiā Biāozhǔn Kuòzhǎn (GBK)

| mime = GBK

| alias = CP936, MS936, windows-936, csGBK

| image = GBK encoding.svg

| caption = Layout of GBK (see below for a larger copy of this diagram)

| standard = GBK 1.0

| lang = Web browsers, decode as GB 18030, supporting all languages, while the encoding (and other software decoders) is primarily used for Simplified Chinese, but also supports Traditional Chinese, Japanese, English, Russian and (partially) Greek.

| status =

| extends = EUC-CN

| prev = GB 2312

| next = GB 18030

| classification = Extended ASCII,{{efn|Not in the strictest sense of the term, as ASCII bytes can appear as trail bytes.}} variable-width encoding, CJK encoding

|extra =

{{notelist}}

}}

GBK is an extension of the GB 2312 character set for Simplified Chinese characters, used in the People's Republic of China. It includes all unified CJK characters found in {{nowrap|GB 13000.1-93}}, i.e. ISO/IEC 10646:1993, or Unicode 1.1. Since its initial release in 1993, GBK has been extended by Microsoft in Code page 936/1386, which was then extended into GBK 1.0. GBK is also the IANA-registered internet name for the Microsoft mapping,{{cite web|title=Character Sets|url=https://www.iana.org/assignments/character-sets/character-sets.xhtml|access-date=3 October 2016}} which differs from other implementations primarily by the single-byte euro sign at 0x80.

GB abbreviates Guójiā Biāozhǔn, which means national standard in Chinese, while K stands for Extension (扩展 kuòzhǎn). GBK not only extended the old standard {{nowrap|GB 2312}} with Traditional Chinese characters, but also with Chinese characters that were simplified after the establishment of {{nowrap|GB 2312}} in 1981. With the arrival of GBK, certain names with characters formerly unrepresentable, like the 镕 (róng) character in former Chinese Premier Zhu Rongji's name, are now representable.{{cite web |url=http://www.microsoft.com/typography/unicode/936.txt |archive-url=https://web.archive.org/web/20021001194325/http://www.microsoft.com/typography/unicode/936.txt |title=Code Page 936 - PRC GBK (XGB) |website=Microsoft |archive-date=2002-10-01 |url-status=dead}} Conversion map between Codepage 936 and Unicode. Need manually selecting GB 18030 or GBK in browser to view it correctly.

{{As of|2022|10}}, GBK is the third-most popular encoding served from China and territories (after UTF-8 and the subset {{nowrap|GB 2312}}), with 1.9% of web servers serving a page that declares GBK.{{Cite web|title=Distribution of Character Encodings among websites that use China and territories|url=https://w3techs.com/technologies/segmentation/sl-cnter-/character_encoding|website=w3techs.com|access-date=2022-10-25}} However, all major web browsers decode GB2312-marked documents as if they were marked GBK, except for Safari and Edge on the label GB_2312.{{Cite web|url=https://www.w3.org/International/tests/repo/results/encoding-dbl-byte-labels.en.html|title=Encoding: Summarized test results|website=www.w3.org|access-date=2019-11-15}} Together, GBK and {{nowrap|GB 2312}} encodings have a combined 5.5% presence in China and territories. Globally, GBK accounts for less than 0.07% of all web pages and GBK+GB2312 for 0.2%.{{Cite web|title=Historical trends in the usage statistics of character encodings for websites, October 2022|url=https://w3techs.com/technologies/history_overview/character_encoding|access-date=2022-10-25|website=w3techs.com}}

History

In 1993, the Unicode 1.1 standard was released, including 20,902 characters used in mainland China, Taiwan, Japan and Korea. Following this, China released {{nowrap|GB 13000.1-93}}, the Guobiao standard equivalent of Unicode 1.1.

{{anchor|1993}}The GBK character set was defined in 1993 as an extension of {{nowrap|GB 2312-80}}, while also including the characters of GB 13000.1-93 through the unused codepoints available in GB 2312. Hence GBK is backward compatible with GB 2312. GBK was defined in a normative annex to GB 13000.1-93.{{cite web |url=https://www.unicode.org/versions/Unicode15.0.0/ch18.pdf#page=28 |p=763 |title=18.2: Ideographic Description Characters |work=The Unicode Standard |version=Version 15.0.0 |year=2022 |quotation=The Ideographic Description characters are found in GBK—an extension to GB 2312-80 that added all 20,902 Unicode Version 1.1 ideographs not already in GB 2312-80. GBK is defined as a normative annex of GB 13000.1-93.}}

{{anchor|cp936}}Microsoft implemented GBK in Windows 95 and Windows NT 3.51 as Code Page 936. While GBK was never an official standard, widespread usage of Windows 95 led to GBK becoming the de facto standard. While GBK included all the Chinese characters defined in Unicode 1.1 and GB 13000.1-93, these standards used different code tables. The primary reason for its existence was simply to bridge the gap between GB 2312-80 and GB 13000.1-93.

{{anchor|GBK 1.0}}In 1995, China National Information Technology Standardization Technical Committee set down the Chinese Internal Code Extension Specification ({{lang-zh|s=汉字内码扩展规范 (GBK)|p=Hànzì Nèimǎ Kuòzhǎn Guīfàn (GBK)}}), Version 1.0, known as GBK 1.0, which is a slight extension of Codepage 936. The newly added 95 characters were not found in GB 13000.1-1993, and were provisionally assigned Unicode PUA code points.{{Cite book|url=https://archive.org/details/GB18030-2005|title=GB 18030-2005: Information Technology—Chinese coded character set|last=Standardization Administration of China (SAC)|date=2005-11-18}}{{Rp|534}}

Microsoft later added the euro sign to Code page 936 and assigned the code 0x80 to it. This is not a valid code point in GBK 1.0.

In 2000, the {{nowrap|GB 18030-2000}} standard was released, superseding yet maintaining compatibility with GBK 1.0. It increased the number of definitions of Chinese characters and extended the number of possible characters through the implementation of four-byte character spaces. The subset of GB 18030 consisting of one-byte and two-byte characters is sometimes also referred to as GBK. Mapping to Unicode has been slightly changed, though, as some characters are now defined in Unicode. In the most up-to-date form of the standard, GB 18030-2005, only 24GB 18030-2005 Standard p.9, 79 characters are still mapped to Unicode PUA (see GB 18030#PUA.)

In 2002, GBK was registered as an IANA charset; the registration uses code page 936 mapping as well as CP936/MS936 aliases, but refers to GBK 1.0 specification. {{anchor|W3C}}W3C's technical recommendation published in 2015{{cite web|title=Encoding Standard # gbk-encoder|url=https://www.w3.org/TR/encoding/#gbk-encoder|website=W3C|access-date=2016-10-02}} defines a GBK encoder as a GB 18030 encoder with a single-byte euro sign and without four-byte sequences (while W3C's GBK decoder specification has no such limitation, decodes as {{nowrap|GB 18030}}, i.e. with same range of letters as all of Unicode).

Encoding

A character is encoded as 1 or 2 bytes. A byte in the range 007F is a single byte that means the same thing as it does in ASCII. Strictly speaking, there are 95 characters and 33 control codes in this range.

A byte with the high bit set indicates that it is the first of 2 bytes. Loosely speaking, the first byte is in the range 81FE (that is, never 80 or FF), and the second byte is 40A0 except 7F for some areas and A1FE for others.

More specifically, the following ranges of bytes are defined:

class="wikitable"

|+GBK Encoding Ranges

rowspan="2"|range || rowspan="2"|byte 1 || rowspan="2"|byte 2 || rowspan="2"|code points || colspan="4"|characters
GB 18030 || GBK 1.0 || Codepage 936 || GB 2312
Level GBK/1A1A9A1FE

|align="right"|846

style="text-align:right;"|718{{rp|8–10}}style="text-align:right;"|717style="text-align:right;"|715style="text-align:right;"|682
Level GBK/2B0F7A1FEstyle="text-align:right;"|6,768colspan="2" style="text-align:right;"|6,763style="text-align:right;"|6,763style="text-align:right;"|6,763
Level GBK/381A040FE except 7Fstyle="text-align:right;"|6,080colspan="2" style="text-align:right;"|6,080style="text-align:right;"|6,080rowspan="6"|
Level GBK/4AAFE40A0 except 7Fstyle="text-align:right;"|8,160colspan="2" style="text-align:right;"|8,160style="text-align:right;"|8,080
Level GBK/5A8A940A0 except 7Fstyle="text-align:right;"|192colspan="2" style="text-align:right;"|166style="text-align:right;"|153
user-defined 1AAAFA1FEstyle="text-align:right;"|564colspan="4" rowspan="3"|
user-defined 2F8FEA1FEstyle="text-align:right;"|658
user-defined 3A1A740A0 except 7Fstyle="text-align:right;"|672
total: || || || style="text-align:right;"|23,940 || style="text-align:right;"|21,887 || style="text-align:right;"|21,886 || style="text-align:right;"|21,791 || style="text-align:right;"|7,445

=Layout diagram=

In graphical form, the following figure shows the space of all 64K possible 2-byte codes. Green and yellow areas are assigned GBK codepoints, red are for user-defined characters. The uncolored areas are invalid byte combinations.

Image:GBK encoding.svg

Relationship to other encodings

The areas indicated in the previous section as GBK/1 and GBK/2, taken by themselves, is simply {{nowrap|GB 2312-80}} in its usual encoding, GBK/1 being the non-hanzi region and GBK/2 the hanzi region. GB 2312, or more properly the EUC-CN encoding thereof, takes a pair of bytes from the range A1FE, like any 94² ISO-2022 character set loaded into GR. This corresponds to the lower-right quarter of the illustration above. However, GB 2312 does not assign any code points to the rows located at AAB0 and F8FE, even though it had staked out the territory. GBK added extensions to these rows. You can see that the two gaps were filled in with user-defined areas.

More significantly, GBK extended the range of the bytes. Having two-byte characters in the ISO-2022 GR range gives a limit of 94²=8,836 possibilities. Abandoning the ISO-2022 model of strict regions for graphics and control characters, but retaining the feature of low bytes being 1-byte characters and pairs of high bytes denoting a character, you could potentially have 128²=16,384 positions. GBK takes part of that, extending the range from A1FE (94 choices for each byte) to 81FE (126 choices) for the first byte and 40FE (191 choices) for the second byte, for a total of 24,066 positions.

Microsoft's Code Page 936 is generally thought of as being GBK. However, the 95 PUA characters added in GBK 1.0 are not included in Code Page 936. Code Page 936 also has a single-byte euro sign at 0x80 which GBK 1.0 doesn't have.{{cite web |last1=Scherer |first1=Markus |title=Re: Fun with GBK & GB2312 |url=http://unicode.org/mail-arch/unicode-ml/y2002-m01/0042.html |website=Unicode Mail List Archive |access-date=4 March 2020 |date=4 January 2002}}

GBK's successor, {{nowrap|GB 18030-2000}}, uses the remaining range available to the second byte ({{code|30}}–{{code|39}}) to further expand the number of possibilities while retaining GBK as a subset.

References

{{reflist}}

Notes

{{notelist}}