Principle please refer to the article below: The basic principle of generating random Chinese character verification code with C #Chinese Character Location Code tableThe relationship between the location code, GB code and the internal code of the machine
1 The Location code is first converted into a hexadecimal number representation
(2) (the hexadecimal representation of the location Code) +2020h= GB code;
(3) GB Code +8080h= machine inner Code
For example, in the case of "Da" in Chinese characters, the area code of "Da" is 2083
1, the area code is 20, the bit number is 83
2. Convert location number 2083 to hexadecimal representation as 1453H
3, 1453H+2020H=3473H, get GB code 3473H
4, 3473H+8080H=B4F3H, get the internal code of the machine for B4F3H
Commonly used Chinese characters in 16-55 districts, of which 55 have a few empty, it should be removed. ///<summary>///randomly produce common Chinese characters///</summary>///<param name= "Count" > to produce the number of Chinese characters </param>/// ;returns> Common Chinese characters </returns> private list<string> generatechinesewords (int count) {list<string> Chinesewords = new list<string> (); Random rm = new Random (); Encoding gb=encoding.getencoding ("gb2312"); for (int i = 0; i < count; i++) {//Get region code (the region code range for common Chinese characters is 16-55) int regioncode = RM. Next (16, 56); Gets the bit code (the bit range is 1-94 because the 90,91,92,93,94 of the 55 zone is empty, therefore excludes it) int positioncode; if (Regioncode = = 55) {//area 55 excludes 90,91,92,93,94 Positioncode = rm. Next (1, 90); else {Positioncode = rm. Next (1, 95); //Convert Location code to internal code int regioncode_machine = Regioncode + 160;//160 that is 16 20h+80h=a0h int positioncode_machine = Positioncode + 160;//160 is 16 20h+80h=a0h//Convert to Kanji byte[] bytes = new byte[] {(byte) regioncode_machine, (byte) Positioncode_machine} ; Chinesewords.add (GB. GetString (bytes)); return chinesewords; }