How to randomly generate a specified number of national standard Chinese characters?

zhaozj2021-02-16  107

In order to make each Chinese character have a national unified code, in 1980, my country promulgated the first Chinese character code national standard: GB2312-80 "Information exchange for Chinese characters coding character set" basic set, this character set is my country Chinese information processing The development foundation of technology is also a unified standard for all Chinese character systems in China. Since the national code is four hexadecimal, in order to facilitate communication, everyone is commonly used to four decimal location code. All national standard Chinese characters and symbols form a 94 × 94 matrix. In this square, each line is called a "zone", and each column is called a "bit", so this square array actually forms a 94 zone (the area code is 0 1 to 94), each There are 94 bits (bit numbers from 01 to 94) in the zone. The area code and the bit number where the Chinese character are located simply together constitute the "location code" of the Chinese characters. In the location code of the Chinese character, the high two is the area code, the low two is the bit number. In the location code, the 01-09 area is 682 special characters, and the 16 ~ 87 district is the Chinese zone, including 6763 Chinese characters. Among them, 16-55 districts are primary Chinese characters (3755 most common Chinese characters, according to the order of pinyin letters), 56-87 districts are secondary Chinese characters (3008 Chinese characters, first order of first order).

So, when we need N any Chinese characters, we don't have to build a full Chinese character, but use the area code to achieve the extraction of common Chinese characters.

The following code can realize the generation of any number of Chinese characters:

Private sub getrndhanzi (Byval n as integer) DIM S () AS String, I as integerim temp1 as integer, temp2 as integerredim s (1 to n) RandomizeFor i = 1 to ntemp1 = 16 int (RND * 72) if Temp1 = 55 TENTEMP2 = INT (RND * 90) 'Level 1 Chinese characters from 1601-1694, 1701-1794, ..... 5401-5494, 5501-5589, 94 * 40-5 = 3755 Chinese characters elseTemp2 = int (RND * 95) 'Secondary Chinese characters from 5601-5694, 5701-5794, ..... 8601-8694, 8701-8794, 94 * 32 = 3008 Chinese characters end IFS (i) = CHR ("& H" & hex (TEMP1 160) & HEX (Temp2 160)) NextdeBug.Print Join (s, "") 'Output End Sub

PRIVATE SUB Command1_Click () DIM I as INTEGERFOR I = 1 To 25 'Generate 1-25 Arbitrary Chinese Characters Getrndhanzi INEXTEND SUB

Output:

The legs are open, the squeezes, squats, squatting, squatting, squatting, smashing, squatting, squatting, squatting, squat squat squat squat squat squat squat squat squat squatting嘎 景 景 薤 薤 锺 榉 囟垤 阗 阗 驿 殒 殒 殒 殒 殒 殒 殒 殒 殒 殒 哧烀 哧烀 哧烀 爝 爝 爝 哧烀 哧烀 哧烀 哧烀 爝 爝就 炳 光 椁旖 鲲颀 鲲颀 狁 狁 媪 降 劾 劾 淳 淳 简 简 简 简 紫 抨 劾 劾 抨 劾 劾 抨 劾 劾 瘿 瘿 瘿 瘿 劾 瘿 瘿 瘿 赅 简 瘿 瘿 赅 瘿 瘿 赅 瘿 瘿 瘿 赅 瘿 觞 觞 简 觞唼 鸽 鸽 乜 夙菀 夙菀 陆 陆 陆 哙 哙 哙 哙 岙湔 岙湔 岙湔 郅峁汩 郅峁汩 控 控 控 懂 懂 懂 控 控 懂 懂 懂Jingsheng Yang, aunt, scrap, hurt, hurt, smashed, jealousy, pure,, 脎 脎 脎 免 免 作 作 稞涑 稞涑 怿 怿 艴 艴 艴 弃 作 燧 聚 燧 怿 怿 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧 燧豕 豕 髑 蚍 蚍 蚍 己 芤 芤 篑 驵 驵 獬 疯 吣酃踱 吣酃踱 吣酃踱 祧 疯 疯 祧帙 帙 帙 怙诖 踉 踉 踉 锍 认 认 认 暝 暝 噬 噬 噬

Attachment:

Chinese characters and location code conversion code:

Function quwei (byval x as string) AS string 'to get a zip code IF ASC (x)> = 0 dam ("& h") quhip ("& h") quimat ("& h") Left (x, 2)) - 160, "00" & Format (CDEC ("& H" & Right (x, 2)) - 160, "00") End FunctionFunction Hanzi (Byval X as String) AS String ' A zone code corresponds to Chinese characters or characters Hanzi = CHR ("& H" & HEX (Val (LEFT (X, 2)) 160) & HEX (Val (Right (x, 2)) 160) End Function

转载请注明原文地址:https://www.9cbs.com/read-13414.html

New Post(0)