GB 2312 | |
Nomimecode: | 1 |
Mime: | GB_2312-80 (GB2312 for usual EUC form) |
Alias: | iso-ir-58, chinese, csGB2312, csISO58GB231280 |
Standard: | GB/T 2312-1980 |
Lang: | Simplified Chinese, English Partial support: Traditional Chinese, Russian, Bulgarian, Greek, Japanese, Italian, Irish, Māori |
Classification: | ISO-2022-compatible DBCS, CJK encoding |
Encodings: |
|
Extensions: | ISO-IR-165 |
Prev: | Chinese telegraph code |
Next: | GBK, GB 18030 |
Otherrelated: | JIS X 0208, KS X 1001 |
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 (Chinese: c=[[wikt:推薦|推荐]]|p=tuījiàn|l=recommendation|labels=no) denotes a non-mandatory standard.[1]
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 .[2] 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.[3] Globally, GB2312 is declared on 0.1% of all web pages.[4] 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
.[5]
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.[6] 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.
While GB/T 2312 covers over 99.99% contemporary Chinese text usage,[7] 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 (Chinese: c=区位|labels=no) form, which specifies a row (Chinese: labels=no|hp=qū|s=区) and the position of the character within the row (cell; Chinese: labels=no|hp=wèi|s=位). (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,[8] thus its qūwèi code is 45-66.
The rows (numbered from 1 to 94) contain characters as follows:
The rows 10–15 and 88–94 are unassigned.
For GB/T 2312-1980, it contains 682 signs and 6763 Chinese Characters.
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>'''
.[9] [10]
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 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.
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.
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.
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.
EUC-CN | GBK/GB18030 subset | GB2312.TXT | Character name[11] | |
---|---|---|---|---|
A1A4 | ||||
A1AA |
Unicode mappings of the interpunct and em dash in the subset of GBK and GB 18030 corresponding to GB/T 2312 (and) differ from those which are listed in GB2312.TXT (and), which is a data file which was previously provided by the Unicode Consortium,[12] although it has been designated as obsolete since August 2011[13] 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,[14] iconv-1.14,[15] php-5.6, ActivePerl-5.20, Java 1.7 and Python 3.4[16] 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.[17]
Other differing mappings have been defined and used by individual vendors, including one from Apple.
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.
This row contains various types of list marker. Lowercase forms of the Roman numerals were not included in the original GB/T 2312[18] nor in GB/T 12345,[6] but are included in both Windows code page 936[19] and GB 18030. A euro sign was also added by GB 18030.
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.[1] Apple mostly maps this row to fullwidth code points as below, but uses non-fullwidth mappings for the overline and yuan sign as above.
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.
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,[20] 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.
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,[21] Windows code page 936,[19] Mac OS Simplified Chinese,[22] and GB 18030. They are seen as "standard extensions to GB 2312".[22] 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.
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.[23]
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.
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,[22] and also included in GB/T 12345,[1] [6] Windows code page 936,[19] Mac OS Simplified Chinese[22] and GB 18030. They are seen as "standard extensions to GB 2312".[22]
GB 6345.1 treats the pinyin in this row as fullwidth, and includes halfwidth counterparts as row 11; GB 18030 does not do this.
GB 5007.1-85 24x24 Bitmap Font Set of Chinese Characters for Information Exchange (Chinese: c=信息交换用汉字 24x24 点阵字模集) is the earliest font template based on GB/T 2312 that features corrections and extensions including:
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.