1 [csharp] 2 ///3 /// 获取汉字的全拼音 4 /// 5 /// 传汉字的字符串 6 ///汉字的字符串的拼音 7 public string GetSpell(string x) 8 { 9 int[] iA = new int[] 10 { 11 -20319 ,-20317 ,-20304 ,-20295 ,-20292 ,-20283 ,-20265 ,-20257 ,-20242 ,-20230 12 ,-20051 ,-20036 ,-20032 ,-20026 ,-20002 ,-19990 ,-19986 ,-19982 ,-19976 ,-19805 13 ,-19784 ,-19775 ,-19774 ,-19763 ,-19756 ,-19751 ,-19746 ,-19741 ,-19739 ,-19728 14 ,-19725 ,-19715 ,-19540 ,-19531 ,-19525 ,-19515 ,-19500 ,-19484 ,-19479 ,-19467 15 ,-19289 ,-19288 ,-19281 ,-19275 ,-19270 ,-19263 ,-19261 ,-19249 ,-19243 ,-19242 16 ,-19238 ,-19235 ,-19227 ,-19224 ,-19218 ,-19212 ,-19038 ,-19023 ,-19018 ,-19006 17 ,-19003 ,-18996 ,-18977 ,-18961 ,-18952 ,-18783 ,-18774 ,-18773 ,-18763 ,-18756 18 ,-18741 ,-18735 ,-18731 ,-18722 ,-18710 ,-18697 ,-18696 ,-18526 ,-18518 ,-18501 19 ,-18490 ,-18478 ,-18463 ,-18448 ,-18447 ,-18446 ,-18239 ,-18237 ,-18231 ,-18220 20 ,-18211 ,-18201 ,-18184 ,-18183 ,-18181 ,-18012 ,-17997 ,-17988 ,-17970 ,-17964 21 ,-17961 ,-17950 ,-17947 ,-17931 ,-17928 ,-17922 ,-17759 ,-17752 ,-17733 ,-17730 22 ,-17721 ,-17703 ,-17701 ,-17697 ,-17692 ,-17683 ,-17676 ,-17496 ,-17487 ,-17482 23 ,-17468 ,-17454 ,-17433 ,-17427 ,-17417 ,-17202 ,-17185 ,-16983 ,-16970 ,-16942 24 ,-16915 ,-16733 ,-16708 ,-16706 ,-16689 ,-16664 ,-16657 ,-16647 ,-16474 ,-16470 25 ,-16465 ,-16459 ,-16452 ,-16448 ,-16433 ,-16429 ,-16427 ,-16423 ,-16419 ,-16412 26 ,-16407 ,-16403 ,-16401 ,-16393 ,-16220 ,-16216 ,-16212 ,-16205 ,-16202 ,-16187 27 ,-16180 ,-16171 ,-16169 ,-16158 ,-16155 ,-15959 ,-15958 ,-15944 ,-15933 ,-15920 28 ,-15915 ,-15903 ,-15889 ,-15878 ,-15707 ,-15701 ,-15681 ,-15667 ,-15661 ,-15659 29 ,-15652 ,-15640 ,-15631 ,-15625 ,-15454 ,-15448 ,-15436 ,-15435 ,-15419 ,-15416 30 ,-15408 ,-15394 ,-15385 ,-15377 ,-15375 ,-15369 ,-15363 ,-15362 ,-15183 ,-15180 31 ,-15165 ,-15158 ,-15153 ,-15150 ,-15149 ,-15144 ,-15143 ,-15141 ,-15140 ,-15139 32 ,-15128 ,-15121 ,-15119 ,-15117 ,-15110 ,-15109 ,-14941 ,-14937 ,-14933 ,-14930 33 ,-14929 ,-14928 ,-14926 ,-14922 ,-14921 ,-14914 ,-14908 ,-14902 ,-14894 ,-14889 34 ,-14882 ,-14873 ,-14871 ,-14857 ,-14678 ,-14674 ,-14670 ,-14668 ,-14663 ,-14654 35 ,-14645 ,-14630 ,-14594 ,-14429 ,-14407 ,-14399 ,-14384 ,-14379 ,-14368 ,-14355 36 ,-14353 ,-14345 ,-14170 ,-14159 ,-14151 ,-14149 ,-14145 ,-14140 ,-14137 ,-14135 37 ,-14125 ,-14123 ,-14122 ,-14112 ,-14109 ,-14099 ,-14097 ,-14094 ,-14092 ,-14090 38 ,-14087 ,-14083 ,-13917 ,-13914 ,-13910 ,-13907 ,-13906 ,-13905 ,-13896 ,-13894 39 ,-13878 ,-13870 ,-13859 ,-13847 ,-13831 ,-13658 ,-13611 ,-13601 ,-13406 ,-13404 40 ,-13400 ,-13398 ,-13395 ,-13391 ,-13387 ,-13383 ,-13367 ,-13359 ,-13356 ,-13343 41 ,-13340 ,-13329 ,-13326 ,-13318 ,-13147 ,-13138 ,-13120 ,-13107 ,-13096 ,-13095 42 ,-13091 ,-13076 ,-13068 ,-13063 ,-13060 ,-12888 ,-12875 ,-12871 ,-12860 ,-12858 43 ,-12852 ,-12849 ,-12838 ,-12831 ,-12829 ,-12812 ,-12802 ,-12607 ,-12597 ,-12594 44 ,-12585 ,-12556 ,-12359 ,-12346 ,-12320 ,-12300 ,-12120 ,-12099 ,-12089 ,-12074 45 ,-12067 ,-12058 ,-12039 ,-11867 ,-11861 ,-11847 ,-11831 ,-11798 ,-11781 ,-11604 46 ,-11589 ,-11536 ,-11358 ,-11340 ,-11339 ,-11324 ,-11303 ,-11097 ,-11077 ,-11067 47 ,-11055 ,-11052 ,-11045 ,-11041 ,-11038 ,-11024 ,-11020 ,-11019 ,-11018 ,-11014 48 ,-10838 ,-10832 ,-10815 ,-10800 ,-10790 ,-10780 ,-10764 ,-10587 ,-10544 ,-10533 49 ,-10519 ,-10331 ,-10329 ,-10328 ,-10322 ,-10315 ,-10309 ,-10307 ,-10296 ,-10281 50 ,-10274 ,-10270 ,-10262 ,-10260 ,-10256 ,-10254 51 }; 52 string[] sA = new string[] 53 { 54 "a","ai","an","ang","ao" 55 56 ,"ba","bai","ban","bang","bao","bei","ben","beng","bi","bian","biao","bie","bin" 57 ,"bing","bo","bu" 58 59 ,"ca","cai","can","cang","cao","ce","ceng","cha","chai","chan","chang","chao","che" 60 ,"chen","cheng","chi","chong","chou","chu","chuai","chuan","chuang","chui","chun" 61 ,"chuo","ci","cong","cou","cu","cuan","cui","cun","cuo" 62 63 ,"da","dai","dan","dang","dao","de","deng","di","dian","diao","die","ding","diu" 64 ,"dong","dou","du","duan","dui","dun","duo" 65 66 ,"e","en","er" 67 68 ,"fa","fan","fang","fei","fen","feng","fo","fou","fu" 69 70 ,"ga","gai","gan","gang","gao","ge","gei","gen","geng","gong","gou","gu","gua","guai" 71 ,"guan","guang","gui","gun","guo" 72 73 ,"ha","hai","han","hang","hao","he","hei","hen","heng","hong","hou","hu","hua","huai" 74 ,"huan","huang","hui","hun","huo" 75 76 ,"ji","jia","jian","jiang","jiao","jie","jin","jing","jiong","jiu","ju","juan","jue" 77 ,"jun" 78 79 ,"ka","kai","kan","kang","kao","ke","ken","keng","kong","kou","ku","kua","kuai","kuan" 80 ,"kuang","kui","kun","kuo" 81 82 ,"la","lai","lan","lang","lao","le","lei","leng","li","lia","lian","liang","liao","lie" 83 ,"lin","ling","liu","long","lou","lu","lv","luan","lue","lun","luo" 84 85 ,"ma","mai","man","mang","mao","me","mei","men","meng","mi","mian","miao","mie","min" 86 ,"ming","miu","mo","mou","mu" 87 88 ,"na","nai","nan","nang","nao","ne","nei","nen","neng","ni","nian","niang","niao","nie" 89 ,"nin","ning","niu","nong","nu","nv","nuan","nue","nuo" 90 91 ,"o","ou" 92 93 ,"pa","pai","pan","pang","pao","pei","pen","peng","pi","pian","piao","pie","pin","ping" 94 ,"po","pu" 95 96 ,"qi","qia","qian","qiang","qiao","qie","qin","qing","qiong","qiu","qu","quan","que" 97 ,"qun" 98 99 ,"ran","rang","rao","re","ren","reng","ri","rong","rou","ru","ruan","rui","run","ruo" 100 101 ,"sa","sai","san","sang","sao","se","sen","seng","sha","shai","shan","shang","shao","she" 102 ,"shen","sheng","shi","shou","shu","shua","shuai","shuan","shuang","shui","shun","shuo","si" 103 ,"song","sou","su","suan","sui","sun","suo" 104 105 ,"ta","tai","tan","tang","tao","te","teng","ti","tian","tiao","tie","ting","tong","tou","tu" 106 ,"tuan","tui","tun","tuo" 107 108 ,"wa","wai","wan","wang","wei","wen","weng","wo","wu" 109 110 ,"xi","xia","xian","xiang","xiao","xie","xin","xing","xiong","xiu","xu","xuan","xue","xun" 111 112 ,"ya","yan","yang","yao","ye","yi","yin","ying","yo","yong","you","yu","yuan","yue","yun" 113 114 ,"za","zai","zan","zang","zao","ze","zei","zen","zeng","zha","zhai","zhan","zhang","zhao" 115 ,"zhe","zhen","zheng","zhi","zhong","zhou","zhu","zhua","zhuai","zhuan","zhuang","zhui" 116 ,"zhun","zhuo","zi","zong","zou","zu","zuan","zui","zun","zuo" 117 }; 118 byte[] B = new byte[2]; 119 string s = ""; 120 char[] c = x.ToCharArray(); 121 for (int j = 0; j < c.Length; j++) 122 { 123 B = System.Text.Encoding.Default.GetBytes(c[j].ToString()); 124 if ((int)(B[0]) <= 160 && (int)(B[0]) >= 0) 125 { 126 s += c[j]; 127 } 128 else 129 { 130 for (int i = (iA.Length - 1); i >= 0; i--) 131 { 132 if (iA[i] <= (int)(B[0]) * 256 + (int)(B[1]) - 65536) 133 { 134 s += sA[i]; 135 break; 136 } 137 } 138 } 139 } 140 return s; 141 } 142 143 ///144 /// 获取汉字的全拼音 145 /// 146 /// 传汉字的字符串 147 ///汉字的字符串的拼音 148 public string GetSpell(string x)149 {150 int[] iA = new int[] 151 { 152 -20319 ,-20317 ,-20304 ,-20295 ,-20292 ,-20283 ,-20265 ,-20257 ,-20242 ,-20230 153 ,-20051 ,-20036 ,-20032 ,-20026 ,-20002 ,-19990 ,-19986 ,-19982 ,-19976 ,-19805 154 ,-19784 ,-19775 ,-19774 ,-19763 ,-19756 ,-19751 ,-19746 ,-19741 ,-19739 ,-19728 155 ,-19725 ,-19715 ,-19540 ,-19531 ,-19525 ,-19515 ,-19500 ,-19484 ,-19479 ,-19467 156 ,-19289 ,-19288 ,-19281 ,-19275 ,-19270 ,-19263 ,-19261 ,-19249 ,-19243 ,-19242 157 ,-19238 ,-19235 ,-19227 ,-19224 ,-19218 ,-19212 ,-19038 ,-19023 ,-19018 ,-19006 158 ,-19003 ,-18996 ,-18977 ,-18961 ,-18952 ,-18783 ,-18774 ,-18773 ,-18763 ,-18756 159 ,-18741 ,-18735 ,-18731 ,-18722 ,-18710 ,-18697 ,-18696 ,-18526 ,-18518 ,-18501 160 ,-18490 ,-18478 ,-18463 ,-18448 ,-18447 ,-18446 ,-18239 ,-18237 ,-18231 ,-18220 161 ,-18211 ,-18201 ,-18184 ,-18183 ,-18181 ,-18012 ,-17997 ,-17988 ,-17970 ,-17964 162 ,-17961 ,-17950 ,-17947 ,-17931 ,-17928 ,-17922 ,-17759 ,-17752 ,-17733 ,-17730 163 ,-17721 ,-17703 ,-17701 ,-17697 ,-17692 ,-17683 ,-17676 ,-17496 ,-17487 ,-17482 164 ,-17468 ,-17454 ,-17433 ,-17427 ,-17417 ,-17202 ,-17185 ,-16983 ,-16970 ,-16942 165 ,-16915 ,-16733 ,-16708 ,-16706 ,-16689 ,-16664 ,-16657 ,-16647 ,-16474 ,-16470 166 ,-16465 ,-16459 ,-16452 ,-16448 ,-16433 ,-16429 ,-16427 ,-16423 ,-16419 ,-16412 167 ,-16407 ,-16403 ,-16401 ,-16393 ,-16220 ,-16216 ,-16212 ,-16205 ,-16202 ,-16187 168 ,-16180 ,-16171 ,-16169 ,-16158 ,-16155 ,-15959 ,-15958 ,-15944 ,-15933 ,-15920 169 ,-15915 ,-15903 ,-15889 ,-15878 ,-15707 ,-15701 ,-15681 ,-15667 ,-15661 ,-15659 170 ,-15652 ,-15640 ,-15631 ,-15625 ,-15454 ,-15448 ,-15436 ,-15435 ,-15419 ,-15416 171 ,-15408 ,-15394 ,-15385 ,-15377 ,-15375 ,-15369 ,-15363 ,-15362 ,-15183 ,-15180 172 ,-15165 ,-15158 ,-15153 ,-15150 ,-15149 ,-15144 ,-15143 ,-15141 ,-15140 ,-15139 173 ,-15128 ,-15121 ,-15119 ,-15117 ,-15110 ,-15109 ,-14941 ,-14937 ,-14933 ,-14930 174 ,-14929 ,-14928 ,-14926 ,-14922 ,-14921 ,-14914 ,-14908 ,-14902 ,-14894 ,-14889 175 ,-14882 ,-14873 ,-14871 ,-14857 ,-14678 ,-14674 ,-14670 ,-14668 ,-14663 ,-14654 176 ,-14645 ,-14630 ,-14594 ,-14429 ,-14407 ,-14399 ,-14384 ,-14379 ,-14368 ,-14355 177 ,-14353 ,-14345 ,-14170 ,-14159 ,-14151 ,-14149 ,-14145 ,-14140 ,-14137 ,-14135 178 ,-14125 ,-14123 ,-14122 ,-14112 ,-14109 ,-14099 ,-14097 ,-14094 ,-14092 ,-14090 179 ,-14087 ,-14083 ,-13917 ,-13914 ,-13910 ,-13907 ,-13906 ,-13905 ,-13896 ,-13894 180 ,-13878 ,-13870 ,-13859 ,-13847 ,-13831 ,-13658 ,-13611 ,-13601 ,-13406 ,-13404 181 ,-13400 ,-13398 ,-13395 ,-13391 ,-13387 ,-13383 ,-13367 ,-13359 ,-13356 ,-13343 182 ,-13340 ,-13329 ,-13326 ,-13318 ,-13147 ,-13138 ,-13120 ,-13107 ,-13096 ,-13095 183 ,-13091 ,-13076 ,-13068 ,-13063 ,-13060 ,-12888 ,-12875 ,-12871 ,-12860 ,-12858 184 ,-12852 ,-12849 ,-12838 ,-12831 ,-12829 ,-12812 ,-12802 ,-12607 ,-12597 ,-12594 185 ,-12585 ,-12556 ,-12359 ,-12346 ,-12320 ,-12300 ,-12120 ,-12099 ,-12089 ,-12074 186 ,-12067 ,-12058 ,-12039 ,-11867 ,-11861 ,-11847 ,-11831 ,-11798 ,-11781 ,-11604 187 ,-11589 ,-11536 ,-11358 ,-11340 ,-11339 ,-11324 ,-11303 ,-11097 ,-11077 ,-11067 188 ,-11055 ,-11052 ,-11045 ,-11041 ,-11038 ,-11024 ,-11020 ,-11019 ,-11018 ,-11014 189 ,-10838 ,-10832 ,-10815 ,-10800 ,-10790 ,-10780 ,-10764 ,-10587 ,-10544 ,-10533 190 ,-10519 ,-10331 ,-10329 ,-10328 ,-10322 ,-10315 ,-10309 ,-10307 ,-10296 ,-10281 191 ,-10274 ,-10270 ,-10262 ,-10260 ,-10256 ,-10254 192 };193 string[] sA = new string[] 194 { 195 "a","ai","an","ang","ao" 196 197 ,"ba","bai","ban","bang","bao","bei","ben","beng","bi","bian","biao","bie","bin" 198 ,"bing","bo","bu" 199 200 ,"ca","cai","can","cang","cao","ce","ceng","cha","chai","chan","chang","chao","che" 201 ,"chen","cheng","chi","chong","chou","chu","chuai","chuan","chuang","chui","chun" 202 ,"chuo","ci","cong","cou","cu","cuan","cui","cun","cuo" 203 204 ,"da","dai","dan","dang","dao","de","deng","di","dian","diao","die","ding","diu" 205 ,"dong","dou","du","duan","dui","dun","duo" 206 207 ,"e","en","er" 208 209 ,"fa","fan","fang","fei","fen","feng","fo","fou","fu" 210 211 ,"ga","gai","gan","gang","gao","ge","gei","gen","geng","gong","gou","gu","gua","guai" 212 ,"guan","guang","gui","gun","guo" 213 214 ,"ha","hai","han","hang","hao","he","hei","hen","heng","hong","hou","hu","hua","huai" 215 ,"huan","huang","hui","hun","huo" 216 217 ,"ji","jia","jian","jiang","jiao","jie","jin","jing","jiong","jiu","ju","juan","jue" 218 ,"jun" 219 220 ,"ka","kai","kan","kang","kao","ke","ken","keng","kong","kou","ku","kua","kuai","kuan" 221 ,"kuang","kui","kun","kuo" 222 223 ,"la","lai","lan","lang","lao","le","lei","leng","li","lia","lian","liang","liao","lie" 224 ,"lin","ling","liu","long","lou","lu","lv","luan","lue","lun","luo" 225 226 ,"ma","mai","man","mang","mao","me","mei","men","meng","mi","mian","miao","mie","min" 227 ,"ming","miu","mo","mou","mu" 228 229 ,"na","nai","nan","nang","nao","ne","nei","nen","neng","ni","nian","niang","niao","nie" 230 ,"nin","ning","niu","nong","nu","nv","nuan","nue","nuo" 231 232 ,"o","ou" 233 234 ,"pa","pai","pan","pang","pao","pei","pen","peng","pi","pian","piao","pie","pin","ping" 235 ,"po","pu" 236 237 ,"qi","qia","qian","qiang","qiao","qie","qin","qing","qiong","qiu","qu","quan","que" 238 ,"qun" 239 240 ,"ran","rang","rao","re","ren","reng","ri","rong","rou","ru","ruan","rui","run","ruo" 241 242 ,"sa","sai","san","sang","sao","se","sen","seng","sha","shai","shan","shang","shao","she" 243 ,"shen","sheng","shi","shou","shu","shua","shuai","shuan","shuang","shui","shun","shuo","si" 244 ,"song","sou","su","suan","sui","sun","suo" 245 246 ,"ta","tai","tan","tang","tao","te","teng","ti","tian","tiao","tie","ting","tong","tou","tu" 247 ,"tuan","tui","tun","tuo" 248 249 ,"wa","wai","wan","wang","wei","wen","weng","wo","wu" 250 251 ,"xi","xia","xian","xiang","xiao","xie","xin","xing","xiong","xiu","xu","xuan","xue","xun" 252 253 ,"ya","yan","yang","yao","ye","yi","yin","ying","yo","yong","you","yu","yuan","yue","yun" 254 255 ,"za","zai","zan","zang","zao","ze","zei","zen","zeng","zha","zhai","zhan","zhang","zhao" 256 ,"zhe","zhen","zheng","zhi","zhong","zhou","zhu","zhua","zhuai","zhuan","zhuang","zhui" 257 ,"zhun","zhuo","zi","zong","zou","zu","zuan","zui","zun","zuo" 258 };259 byte[] B = new byte[2];260 string s = "";261 char[] c = x.ToCharArray();262 for (int j = 0; j < c.Length; j++)263 {264 B = System.Text.Encoding.Default.GetBytes(c[j].ToString());265 if ((int)(B[0]) <= 160 && (int)(B[0]) >= 0)266 {267 s += c[j];268 }269 else270 {271 for (int i = (iA.Length - 1); i >= 0; i--)272 {273 if (iA[i] <= (int)(B[0]) * 256 + (int)(B[1]) - 65536)274 {275 s += sA[i];276 break;277 }278 }279 }280 }281 return s;282 }