C # Chinese character turning pinyin

xiaoxiao2021-04-03  253

///

/// Gets a string of Chinese characters /// /// Unicode format Chinese characters /// Pinyin homogene string public static string convert (string Chinese) {char [] buffer = new char [chinese.Length]; for (int i = 0; i

///

/// Get a Chinese character Pinyin Shengmu /// /// Unicode format /// Chinese characters Socoon public static char convert (char Chinese) {eNCoding GB2312 = Encoding.Getencoding ("GB2312"); Encoding Unicode = Encoding.unicoDE

// Convert the string inTo a byte []. Byte [] unicodebytes = unicode.getbytes (new char [] {Chinese}; // perform the conversion from one encoding to the iboding.byte [] ASCIBYTES = Encoding.convert Unicode, GB2312, Unicodebytes;

// Calculate the Chinese characters GB-2312 encoded int n = (int) ASCIBYTES [0] << 8; n = (int) ASCIBYTES [1];

/ / Obtain Pinyin Sonic IF (IN (0xB0A1, 0XB0C4, N)) Return 'A'; IF (IN (0xB0C5, 0XB2C0, N)) Return 'B'; IF (IN (0xB2C1, 0XB4ED, N) )) RETURN 'C'; IF (IN (0xB4EE, 0XB6E9, N)) RETURN 'D'; IF (IN (0xB6EA, 0xB7A1, N)) Return 'E'; IF (in (0xB7A2, 0XB8c0, N))) Return 'f'; IF (IN (0xB8C1, 0XB9FD, N)) RETURN 'G'; IF (in (0xB9FE, 0XBBF6, N)) Return 'h'; IF (in (0xBBF7, 0XBFA5, N)) Return ' J '; IF (IN (0xBFA6, 0XC0AB, N)) Return' k '; IF (in (0xc0ac, 0xC2e7, N)) Return' L '; IF (in (0xC2e8, 0xc4c2, n)) Return' m ' ; IF (IN (0xC4C3, 0XC5B5, N)) Return 'N'; IF (IN (0xC5B6, 0XC5BD, N)) Return 'o'; if (IN (0xc5be, 0xc6d9, N)) Return 'p'; IF (IN (0xC6DA, 0xC8BA, N)) RETURN 'q'; IF (IN (0xC8BB, 0XC8F5, N)) RETURN 'R'; IF (IN (0xC8F6, 0XCBF0, N)) Return 's'; IF (in (0xcbfa, 0xcdd9, n)) Return 'T'; IF (IN (0xCDDA, 0xCEF3, N)) RETURN 'W'; IF (in (0xCEF4, 0XD188, N)) Return 'x'; if (in (0xD1b9 , 0xD4D0, N)) RETURN 'Y'; IF (IN (0xD4D1, 0XD7F9, N)) Return 'Z'; Return '/ 0';} Private Static Bool In (int LP, INT HP, INT VALUE) {Return ((Value <= HP) && (Value> = LP));

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

New Post(0)