GB 2312-80 is China's national standard simplified Chinese character set, the full name is "Chinese Coded Character Set for Information Exchange·Basic Set", published by the State Administration of Standards of China and implemented on May 1, 1981. GB2312 encoding is popular in mainland China; Singapore and other places also use this encoding. Almost all Chinese systems and international software in mainland China support GB 2312.
GB2312 standard contains a total of 6763 Chinese characters, including 3755 first-level Chinese characters and 3008 second-level Chinese characters; it also includes Latin letters, Greek letters, Japanese hiragana and katakana letters, Russian Siri 682 characters including Er letters. The emergence of GB2312 basically meets the computer processing needs of Chinese characters. The Chinese characters it contains have covered 99.75% of the frequency of use in mainland China. GB2312 cannot handle rare characters that appear in personal names, ancient Chinese, etc., which led to the emergence of the later GBK and GB18030 Chinese character sets.
GB2312 “partitions” the collected Chinese characters, and each zone contains 94 Chinese characters/symbols. This representation is also called location code.
01 - 09 area is a special symbol.
16 - Area 55 is the first-level Chinese characters, sorted by pinyin.
56 - 87 area is the second level Chinese characters, sorted by radical/stroke.
Districts 10-15 and 88-94 are not coded. For example, the character "ah" is the first Chinese character in GB2312, and its location code is 1601.
Each Chinese character and symbol is represented by two bytes. The first byte is called the "high byte" and the second byte is called the "low byte". The "high byte" uses 0xA1 - 0xF7 (add 0xA0 to the area code of area 01 - 87), and the "low byte" uses 0xA1 - 0xFE (add 0xA0 to the area code of 01 - 94). Since the first-level Chinese characters start from area 16, the "high byte" range of the Chinese character area is 0xB0 - 0xF7, the "low byte" range is 0xA1 - 0xFE, and the occupied code bits are 72 * 94 = 6768. 5 of the slots available are D7FA - D7FE. For example, in most programs, the word "Ah" will be stored in two bytes, 0xB0 (the first byte) and 0xA1 (the second byte). (Compare with area code: 0xB0 = 0xA0 + 16, 0xA1 = 0xA0 + 1).
National standard GB 18030-2005 "Information Technology Chinese Coded Character Set" is the latest internal code character set of the People's Republic of China. It is fully compatible with GB 2312-1980, basically compatible with GBK, and supports GB 13000 and All unified Chinese characters in Unicode include a total of 70,244 Chinese characters. The current version was released by the State Administration of Quality Supervision and Inspection and the China National Standardization Administration Committee on November 8, 2005, and was implemented on May 1, 2006. It is a mandatory standard supported by all software products in China.
function getChar($num) // $num为生成汉字的数量 { $b = ''; for ($i=0; $i<$num; $i++) { // 使用chr()函数拼接双字节汉字,前一个chr()为高位字节,后一个为低位字节 $a = chr(mt_rand(0xB0,0xD0)).chr(mt_rand(0xA1, 0xF0)); // 转码 $b .= iconv('GB2312', 'UTF-8', $a); } return $b; }
Related recommendations:
sqlserver Function to quickly generate the first letters of Chinese characters (classic)
The above is the detailed content of Implementation method of randomly generating Chinese characters in PHP. For more information, please follow other related articles on the PHP Chinese website!