GB 2312

is a key official character set of the People's Republic of China, used for Simplified Chinese characters. GB2312 is the registered internet name for EUC-CN, which is its usual encoded form. GB refers to the Guobiao standards (国家标准), whereas the T suffix () denotes a non-mandatory standard.

 was originally a mandatory national standard designated . However, following a National Standard Bulletin of the People's Republic of China in 2017, GB 2312 is no longer mandatory, and its standard code is modified to .  has been superseded by GBK and GB 18030, which include additional characters, but  remains in widespread use as a subset of those encodings.

, GB2312 is the second-most popular encoding served from China and territories (after UTF-8), with 5.5% of web servers serving a page declaring it. Globally, GB2312 is declared on 0.1% of all web pages. However, all major web browsers decode GB2312-marked documents as if they were marked with the superset GBK encoding, except for Safari and Edge on the label GB_2312.

There is an analogous character set known as GB/T 12345 Code of Chinese ideogram set for information interchange supplementary set, which supplements GB/T 2312 with traditional character forms by replacing simplified forms in their qūwèi code, and some extra 62 supplemental characters. GB-encoded fonts often come in pairs, one with the GB/T 2312 (simplified) character set and the other with the GB/T 12345 (traditional) character set. There exists more GB supplementary encoding sets that supplements GB/T 2312, including GB/T 7589 Code of Chinese ideograms set forinformation interchange--The 2nd supplementary set and GB/T 7590 Code of Chinese ideograms set forinformation interchange--The 4th supplementary set which provides additional [Variant Chinese characters|variant characters] in the same qūwèi encoding format (later used in ISO-2022-CN), but has no relation with characters encoded in GB/T 2312.

Character range in rows 
While GB/T 2312 covers over 99.99% contemporary Chinese text usage, historical texts and many names remain out of scope. Old  standard includes 6,763 Chinese characters (on two levels: the first is arranged by reading, the second by radical then number of strokes), along with symbols and punctuation, Japanese kana, the Greek and Cyrillic alphabets, Zhuyin, and a double-byte set of Pinyin letters with tone marks. In later version GB/T 2312-1980, there are 7,445 letters.

Characters in GB/T 2312 are arranged in a 94×94 grid (as in ISO 2022), and the two-byte code point of each character is expressed in the qūwèi () form, which specifies a row () and the position of the character within the row (cell; ). (This structure is the same as used by other ISO-2022-based national CJK character set standards; compare kuten.) For example, the character "外" (meaning: foreign) is located in row 45 position 66, thus its qūwèi code is 45-66.

The rows (numbered from 1 to 94) contain characters as follows:

 01–09, comprising punctuation and other special characters; also Hiragana, Katakana, Greek, Cyrillic, Pinyin, Bopomofo
 16–55, the first level of Chinese characters, arranged according to Pinyin. (3755 characters).
 56–87, the second level of Chinese characters, arranged according to radical and strokes. (3008 characters).

The rows 10–15 and 88–94 are unassigned.

For GB/T 2312-1980, it contains 682 signs and 6763 Chinese Characters.

Encodings of GB/T 2312

EUC-CN 
EUC-CN is often used as the character encoding (i.e. for external storage) in programs that deal with GB/T 2312, thus maintaining compatibility with ASCII. Two bytes are used to represent every character not found in ASCII. The value of the first byte is from 0xA1–0xF7 (161–247), while the value of the second byte is from 0xA1–0xFE (161–254). Since all of these ranges are beyond ASCII, like UTF-8, it is possible to check if a byte is part of a multi-byte construct when using EUC-CN, but not if a byte is first or last.

Compared to UTF-8, GB/T 2312 (whether native or encoded in EUC-CN) is more storage efficient: while UTF-8 uses three bytes per CJK ideograph, GB/T 2312 only uses two. However, GB/T 2312 does not cover as many ideographs as Unicode does.

To map the qūwèi code points to EUC bytes, add 160 (0xA0) to both the row number (or qū, 区) and cell/column number (ten or wèi, 位). The result of addition to the row number of the code point will form the high byte, and the result of addition to the cell number of the code point will form the low byte.

For example, to encode the character "外" at qūwèi cell 45-66, the high byte will use the row number 45: 45+160=205=0xCD, and the low byte will come from the cell number 66: 66+160=226=0xE2. So, the full encoding is <CD E2>.

ISO-2022-CN 
ISO-2022-CN is another encoding form of GB/T 2312, which is also the encoding specified in the official documentation. This encoding references the ISO-2022 standard, which also uses two bytes to encode characters not found in ASCII. However, instead of using the extended region of ASCII, ISO-2022 uses the same byte range as ASCII: the value of the first byte is from 0x21–0x77 (33–119), while the value of the second byte is from 0x21–0x7E (33–126). As the byte range overlaps ASCII significantly, special characters are required to indicate whether a character is in the ASCII range or is part of the two-byte sequence of extended region, namely the Shift Out and Shift In functions. This poses a risk for misencoding as improper handling of text can result in missing information.

To map the qūwèi code points to ISO-2022 bytes, add 32 (0x20) to both the row number (or qū, 区) and cell/column number (or wèi, 位). The result of addition to the row number of the code point will form the high byte, and the result of addition to the cell number of the code point will form the low byte similar to EUC encoding.

For example, to encode the character "外" at qūwèi cell 45-66, the high byte will use the row number 45: 45+32=77=0x4D, and the low byte will come from the cell number 66: 66+32=98=0x62. So, the full encoding is <4D 62>.

HZ 
HZ is another encoding of GB/T 2312 that is used mostly for Usenet postings; characters are represented with the same byte pairs as in ISO-2022-CN, but the byte sequences denoting the beginning and end of a range of GB 2312 text differ.

Code charts 
In the tables below, where a pair of hexadecimal numbers is given for a prefix byte or a coding byte, the smaller (with the eighth bit unset or unavailable) is used when encoded over GL (0x21-0x7E), as in ISO-2022-CN or HZ-GB-2312, and the larger (with the eighth bit set) is used in the more typical case of it being encoded over GR (0xA1-0xFE), as in EUC-CN, GBK or GB 18030. Qūwèi numbers are given in decimal.

When GB/T 2312 is encoded over GR, both bytes have the eighth bit set (i.e. are greater than 0x7F). GBK and GB 18030 also make use of two-byte codes in which only the first byte has the eighth bit set for extension purposes: such codes are outside of the GB/T 2312 plane, and are not tabulated here.

Lead byte 
This chart details the overall layout of the main plane of the GB/T 2312 character set by lead byte. For lead bytes used for characters other than hanzi, links are provided to charts on this page listing the characters encoded under that lead byte. For lead bytes used for hanzi, links are provided to the appropriate section of Wiktionary's hanzi index.

Non-Hanzi rows 
The following charts list the non-hanzi characters available in GB/T 2312, in GB/T 12345, and in double-byte region 1 of GB 18030 (which roughly corresponds to the non-hanzi region of GB/T 2312). Notes are made where these differ, and where GB 6345.1 and ISO-IR-165 differ from these. Cross-references are made to articles on other CJK national character sets for comparison.

Two implementations of GB2312 

Unicode mappings of the interpunct () and em dash () in the subset of GBK and GB 18030 corresponding to GB/T 2312 ( and ) differ from the those which are listed in GB2312.TXT ( and ), which is a data file which was previously provided by the Unicode Consortium, although it has been designated as obsolete since August 2011 and is no longer hosted as of September 2016.

As of 2015, Microsoft .Net Framework follows GB 18030 mappings when mapping those two characters in data labelled , whereas ICU, iconv-1.14, php-5.6, ActivePerl-5.20, Java 1.7 and Python 3.4 follow GB2312.TXT in response to the  label. Ruby 2.2 is compatible with both implementations; it internally converts the conflictive characters to the GB 18030 subset. The W3C/WHATWG technical recommendation for use with HTML5 specifies a GBK encoding to be inferred for streams labelled gb2312, which in turn uses a GB18030 decoder.

Other differing mappings have been defined and used by individual vendors, including one from Apple.

Character set 0x21/0xA1 (row 1: punctuation and symbols) 
This row contains punctuation, mathematical operators, and other symbols. The following table shows the GB 18030 mappings for these GB/T 2312 characters first, followed by any other documented mappings.

Character set 0x22/0xA2 (row 2: list markers) 
This row contains various types of list marker. Lowercase forms of the Roman numerals were not included in the original GB/T 2312 nor in GB/T 12345, but are included in both Windows code page 936 and GB 18030. A euro sign was also added by GB 18030.

Character set 0x23/0xA3 (row 3: ISO 646-CN) 
This row contains ISO 646-CN (GB/T 1988-80), a national counterpart to ASCII. Compare row 3 of KS X 1001, which does the same with South Korea's ISO 646 version, and row 3 of JIS X 0208 and of KPS 9566, which include only the alphanumeric subset, but in the same layout. The following chart lists ISO 646-CN.

When used in an encoding allowing combination with ASCII such as EUC-CN (and its superset GB 18030), these characters are usually implemented as fullwidth characters, hence mappings to the Halfwidth and Fullwidth Forms block are used as shown below. GB 6345.1 also handles this row as fullwidth, and adds the halfwidth forms (as above) as row 10. Apple mostly maps this row to fullwidth code points as below, but uses non-fullwidth mappings for the overline and yuan sign as above.

Character set 0x24/0xA4 (row 4: Hiragana) 
This set contains Hiragana for writing the Japanese language.

Compare with row 4 of JIS X 0208, which this row matches, and with row 10 of KS X 1001 and of KPS 9566, which use the same layout, but in a different row.

Character set 0x25/0xA5 (row 5: Katakana) 
This set contains Katakana for writing the Japanese language. However, the Japanese long vowel mark, which is used in katakana text and included in row 1 of JIS X 0208, is not included in GB/T 2312, although it is added in GBK and GB 18030 outside of the main GB/T 2312 plane, at 0xA960.

Compare with row 5 of JIS X 0208, which this row matches, and with row 11 of KS X 1001 and of KPS 9566, which use the same layout, but in a different row.

Character set 0x26/0xA6 (row 6: Greek and vertical extensions) 
This row contains basic support for the modern Greek alphabet, without diacritics or the final sigma.

The highlighted characters are presentation forms of punctuation marks for vertical writing, and are not included in GB/T 2312 proper, but are included in this row by GB/T 12345, Windows code page 936, Mac OS Simplified Chinese, and GB 18030. They are seen as "standard extensions to GB 2312". Conversely, ISO-IR-165 includes patterned semigraphic characters in this row (mostly without exact counterparts in Unicode), colliding with the code positions used for the vertical extensions.

Compare with row 6 of JIS X 0208, which this row matches when the vertical forms are not included, and with row 6 of KPS 9566, which includes the same Greek letters in the same layout, but adds Roman numerals rather than vertical forms. Contrast row 5 of KS X 1001, which offsets the Greek letters to include the Roman numerals first.

Character set 0x27/0xA7 (row 7: Cyrillic) 
This set includes both cases of 33 letters from the Cyrillic script, sufficient to write the modern Russian alphabet and Bulgarian alphabet, although other forms of Cyrillic require additional letters.

Compare with row 7 of JIS X 0208, which this row matches, and with row 12 of KS X 1001 and row 5 of KPS 9566, which use the same layout but in different rows.

Character set 0x28/0xA8 (row 8: zhuyin and non-ASCII pinyin) 
This row contains bopomofo and pinyin characters, excluding ASCII letters (which are in row 3). The highlighted characters are those which are not in the base GB 2312 set but are added by GB 6345.1, and also included in GB/T 12345, Windows code page 936, Mac OS Simplified Chinese and GB 18030. They are seen as "standard extensions to GB 2312".

GB 6345.1 treats the pinyin in this row as fullwidth, and includes halfwidth counterparts as row 11; GB 18030 does not do this.

Character set 0x29/0xA9 (row 9: box drawing)

Hanzi rows

Corrections 
GB 5007.1-85 24x24 Bitmap Font Set of Chinese Characters for Information Exchange () is the earliest font template based on GB/T 2312 that features corrections and extensions including:
 changing the glyph shape of Latin alphabet "g"
 adding 6 Hanyu Pinyin characters: ɑ, ḿ, ń, ň, ǹ, ɡ
 changed “” to “”
 included 94 half-width glyphs in row 10 (half-width form of row 3, equivalent to GB 1988–80
 included half-width form of 32 Hanyu Pinyin characters from row 8 in row 11.

GB/T 2312 did not have corrections, but these corrections are included in font templates that are based on GB/T 2312 including GB/T 12345; its supersets GBK and GB 18030 also included these corrections. GB/T 2312 is also used in  ISO-IR-165.

See also 
 Guobiao code
 CJK
 Chinese character encoding
 Unicode
 Big5 standard used in Taiwan and Hong Kong
 GB 18030, which has superseded GB/T 2312-1980
 GB/T 12345-1990, traditional counterpart of GB/T 2312-1980, superseded by GB18030

References

Notes

Further reading

External links 
 Graphical View of GB2312 in ICU's Converter Explorer
 Unicode to GB2312 or GBK table
 Chinese Character Codes
 Evolution of GBK and GB2312 into GB18030
 GB2312 Character Set for Chinese Characters
 Coded Chinese Graphic Character Set for Information Interchange ISO-IR 58
 C code generates 6763 basic characters with output
 GB2312-80 standard on China-Language.gov.cn

Character sets
2312
Encodings of Asian languages
Chinese-language computing