[C #] Enter the first letter of the Chinese character string index

xiaoxiao2021-03-06  65

When you do a project, enter the customer's name. In order to make it easy to index the Chinese character string, make a record, so I will find it online, it is ok, there is a single Chinese character to handle! In order to thank the netizen! For future netizens, I made the handling of Chinese characters! Please ask your netizens to advise Shixiang9076@sina.com! Using system.drawing; using system.componentmodel; using system.windows.form; using system.data;

Summary description of Namespace Winmarket {///

/// ClassFun. /// public class classfun {private string capstr; public classfun () {// // Todo: Add constructor logic //} public string chinesecap (string chineseStr) {byte [] zw = new Byte [2]; long chinesester_int; string charstr, chinastr = ""; for (int i = 0; i <= chineseStr.length-1; i ) {charstr = Chineseestr.substring (i, 1) .tostring (); ZW = system.text.Encoding.default.getbytes (charstr); // Get the byte array IF of the Chinese character (zw.Length == 2) {INT I1 = (ZW [0]); int I2 = (short) (ZW [1]); chineseSTR_INT = I1 * 256 I2; // Table of the constant list // 'a'; //45217..45252 // 'b'; //45253..45760 / / 'C'; //45761..46317 // 'd'; //46318..46825 // 'e'; //46826..47009 // 'f'; //47010..47296 // ' G '; //47297..47613

// 'h'; //47614..48118 // 'j'; //48119..49061 // 'k'; //49062..49323 // 'L'; //49324..49895 ///// 'M'; //49896..50370 // 'n'; //50371..50613 // 'o'; //50614..50621 // 'p'; //50622..50905 // 'q '; //50906..51386

// 'r'; //51387..51445 // 's'; //51446..52217 // 't'; //52218..52697 // no u, v // 'w'; // 52698..52979 // 'x'; //52980..53640 // 'y'; //53689..54480 // 'z'; //54481..55289 IF ((ChineseSTR_INT> = 45217) && ChineseSTR_INT <= 45252)) {chinastr = "a";} else if ((ChineseSTR_INT> = 45253) && (ChineseSTR_INT <= 45760) {chinastr = "b";} else if ((ChineseSTR_INT> = 45761) && ChineseSTR_INT <= 46317)) {chinastr = "c";

} Else IF ((ChineseSTR_INT> = 46318) && (ChineseSTR_INT <= 46825)) {chinastr = "d";} else} ((ChineseSTR_INT> = 46826) && (ChineseSTR_INT <= 47009)) {chinastr = "e"; } Else if ((ChineseSTR_INT> = 47010) && (ChineseSTR_INT <= 47296)) {chinastr = "f";} else} ((ChineseSTR_INT> = 47297) && (ChineseSTR_INT <= 47613)) {chinastr = "g"; } Else IF ((ChineseSTR_INT> = 47614) && (ChineseSTR_INT <= 48118)) {chinastr = "h";} else f ((ChineseSTR_INT> = 48119) && (ChineseSTR_INT <= 49061)) {chinastr = "j"; } Else if ((ChineseSTR_INT> = 49062) && (ChineseSTR_INT <= 49323)) {chinastr = "k";} else} ((ChineseSTR_INT> = 49324) && (ChineseSTR_INT <= 49895) {chinastr = "l"; } Else if ((ChineseSTR_INT> = 49896) && (ChineseSTR_INT <= 50370)) {chinastr = "m";} else} ((ChineseSTR_INT> = 50371) && (ChineseSTR_INT <= 50613)) {chin astr = "n";

} Else if ((ChineseSTR_INT> = 50614) && (ChineseSTR_INT <= 50621)) {chinastr = "o";} else} ((ChineseSTR_INT> = 50622) && (ChineseSTR_INT <= 50905)) {chinastr = "p";

} Else IF ((ChineseSTR_INT> = 50906) && (ChineseSTR_INT <= 51386)) {chinastr = "q";} else IF ((ChineseSTR_INT> = 51387) && (ChineseSTR_INT <= 51445) {chinastr = "r"; } Else IF ((ChineseSTR_INT> = 51444) && (ChineseSTR_INT <= 52217)) {chinastr = "s";} else} ((ChineseSTR_INT> = 52218) && (ChineseSTR_INT <= 52697)) {chinastr = "t"; } Else IF ((ChineseSTR_INT> = 52698) && (ChineseSTR_INT <= 52979)) {chinastr = "w";} else f ((ChineseSTR_INT> = 52980) && (ChineseSTR_INT <= 53640)) {chinastr = "x"; } Else if ((ChineseSTR_INT> = 53689) && (ChineseSTR_INT <= 54480) {chinastr = "y";} else} ((ChineseSTR_INT> = 54481) && (ChineseSTR_INT <= 55289) {chinastr = "z"; }} Else {Capstr = ChineseStr; Break;} Capstr = Capstr chinastr;}

Return Capstr;

}}}

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

New Post(0)