第一种方法
//将指定字符串中的汉字转换为拼音缩写,其中非汉字保留为原字符。 public string GetPinYin(string text) { char pinyin; byte[] array; System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length);
foreach(char c in text) { pinyin = c; array = System.Text.Encoding.Default.GetBytes(new char[]{c});
if(array.Length == 2) { int i = array[0] * 0x100 + array[1];
if(i < 0xB0A1) pinyin = c; else if(i < 0xB0C5) pinyin = ‘a‘; else if(i < 0xB2C1) pinyin = ‘b‘; else if(i < 0xB4EE) pinyin = ‘c‘; else if(i < 0xB6EA) pinyin = ‘d‘; else if(i < 0xB7A2) pinyin = ‘e‘; else if(i < 0xB8C1) pinyin = ‘f‘; else if(i < 0xB9FE) pinyin = ‘g‘; else if(i < 0xBBF7) pinyin = ‘h‘; else if(i < 0xBFA6) pinyin = ‘g‘; else if(i < 0xC0AC) pinyin = ‘k‘; else if(i < 0xC2E8) pinyin = ‘l‘; else if(i < 0xC4C3) pinyin = ‘m‘; else if(i < 0xC5B6) pinyin = ‘n‘; else if(i < 0xC5BE) pinyin = ‘o‘; else if(i < 0xC6DA) pinyin = ‘p‘; else if(i < 0xC8BB) pinyin = ‘q‘; else if(i < 0xC8F6) pinyin = ‘r‘; else if(i < 0xCBFA) pinyin = ‘s‘; else if(i < 0xCDDA) pinyin = ‘t‘; else if(i < 0xCEF4) pinyin = ‘w‘; else if(i < 0xD1B9) pinyin = ‘x‘; else if(i < 0xD4D1) pinyin = ‘y‘; else if(i < 0xD7FA) pinyin = ‘z‘; }
sb.Append(pinyin); }
return sb.ToString(); }
第二种方法
ASP.NET(C#)汉字转换成拼音的源代码
2009-10-16 17:39:31| 分类: 网络技术 |字号 订阅
using System;
using System.Collections;
using System.Text;
namespace Son1c.String
{
/// <summary>
/// Son1c 的摘要说明。
/// </summary>
/// 汉字转化成拼音#region 汉字转化成拼音
public class Chinese2Spell
{
/// <summary>
/// 获得拼音
/// </summary>
/// <param name="str_Spell">汉字</param>
/// <returns></returns>
///调用格式:GetSpell(string str_Spell)
///str_Spell是要转换的汉字
///返回结果是转化成的拼音
///目前还不完善,例如“爨”字转换不出来,需要进一步完善
public string GetSpell(string str_Chinese)
{
try
{
Hashtable t = hb();
byte[] b = System.Text.Encoding.Default.GetBytes(str_Chinese);
int p;
StringBuilder ret = new StringBuilder();
for (int i = 0; i < b.Length; i++)
{
p = (int)b;
if (p > 128)//160? or 128? 原文是,待以后考证
{
p = p * 256 + b[++i] - 65536;
ret.Append(g(t, p));
}
else
{
ret.Append((char)p);
}
}
t.Clear();
return ret.ToString();
}
catch
{
return "";
}
}
private string g(Hashtable ht, int num)
{
if (num < -20319 || num > -10247)
return "";
while (!ht.ContainsKey(num))
num--;
return ht[num].ToString();
}
private Hashtable hb()
{
//尚不晚完善,例如“爨”就没有转换出来
Hashtable ht = new Hashtable();
ht.Add(-20319, "a");
ht.Add(-20317, "ai"); ht.Add(-20304, "an"); ht.Add(-20295, "ang");
ht.Add(-20292, "ao"); ht.Add(-20283, "ba"); ht.Add(-20265, "bai");
ht.Add(-20257, "ban"); ht.Add(-20242, "bang"); ht.Add(-20230, "bao");
ht.Add(-20051, "bei"); ht.Add(-20036, "ben"); ht.Add(-20032, "beng");
ht.Add(-20026, "bi"); ht.Add(-20002, "bian"); ht.Add(-19990, "biao");
ht.Add(-19986, "bie"); ht.Add(-19982, "bin"); ht.Add(-19976, "bing");
ht.Add(-19805, "bo"); ht.Add(-19784, "bu"); ht.Add(-19775, "ca");
ht.Add(-19774, "cai"); ht.Add(-19763, "can"); ht.Add(-19756, "cang");
ht.Add(-19751, "cao"); ht.Add(-19746, "ce"); ht.Add(-19741, "ceng");
ht.Add(-19739, "cha"); ht.Add(-19728, "chai"); ht.Add(-19725, "chan");
ht.Add(-19715, "chang"); ht.Add(-19540, "chao"); ht.Add(-19531, "che");
ht.Add(-19525, "chen"); ht.Add(-19515, "cheng"); ht.Add(-19500, "chi");
ht.Add(-19484, "chong"); ht.Add(-19479, "chou"); ht.Add(-19467, "chu");
ht.Add(-19289, "chuai"); ht.Add(-19288, "chuan"); ht.Add(-19281, "chuang");
ht.Add(-19275, "chui"); ht.Add(-19270, "chun"); ht.Add(-19263, "chuo");
ht.Add(-19261, "ci"); ht.Add(-19249, "cong"); ht.Add(-19243, "cou");
ht.Add(-19242, "cu"); ht.Add(-19238, "cuan"); ht.Add(-19235, "cui");
ht.Add(-19227, "cun"); ht.Add(-19224, "cuo"); ht.Add(-19218, "da");
ht.Add(-19212, "dai"); ht.Add(-19038, "dan"); ht.Add(-19023, "dang");
ht.Add(-19018, "dao"); ht.Add(-19006, "de"); ht.Add(-19003, "deng");
ht.Add(-18996, "di"); ht.Add(-18977, "dian"); ht.Add(-18961, "diao");
ht.Add(-18952, "die"); ht.Add(-18783, "ding"); ht.Add(-18774, "diu");
ht.Add(-18773, "dong"); ht.Add(-18763, "dou"); ht.Add(-18756, "du");
ht.Add(-18741, "duan"); ht.Add(-18735, "dui"); ht.Add(-18731, "dun");
ht.Add(-18722, "duo"); ht.Add(-18710, "e"); ht.Add(-18697, "en");
ht.Add(-18696, "er"); ht.Add(-18526, "fa"); ht.Add(-18518, "fan");
ht.Add(-18501, "fang"); ht.Add(-18490, "fei"); ht.Add(-18478, "fen");
ht.Add(-18463, "feng"); ht.Add(-18448, "fo"); ht.Add(-18447, "fou");
ht.Add(-18446, "fu"); ht.Add(-18239, "ga"); ht.Add(-18237, "gai");
ht.Add(-18231, "gan"); ht.Add(-18220, "gang"); ht.Add(-18211, "gao");
ht.Add(-18201, "ge"); ht.Add(-18184, "gei"); ht.Add(-18183, "gen");
ht.Add(-18181, "geng"); ht.Add(-18012, "gong"); ht.Add(-17997, "gou");
ht.Add(-17988, "gu"); ht.Add(-17970, "gua"); ht.Add(-17964, "guai");
ht.Add(-17961, "guan"); ht.Add(-17950, "guang"); ht.Add(-17947, "gui");
ht.Add(-17931, "gun"); ht.Add(-17928, "guo"); ht.Add(-17922, "ha");
ht.Add(-17759, "hai"); ht.Add(-17752, "han"); ht.Add(-17733, "hang");
ht.Add(-17730, "hao"); ht.Add(-17721, "he"); ht.Add(-17703, "hei");
ht.Add(-17701, "hen"); ht.Add(-17697, "heng"); ht.Add(-17692, "hong");
ht.Add(-17683, "hou"); ht.Add(-17676, "hu"); ht.Add(-17496, "hua");
ht.Add(-17487, "huai"); ht.Add(-17482, "huan"); ht.Add(-17468, "huang");
ht.Add(-17454, "hui"); ht.Add(-17433, "hun"); ht.Add(-17427, "huo");
ht.Add(-17417, "ji"); ht.Add(-17202, "jia"); ht.Add(-17185, "jian");
ht.Add(-16983, "jiang"); ht.Add(-16970, "jiao"); ht.Add(-16942, "jie");
ht.Add(-16915, "jin"); ht.Add(-16733, "jing"); ht.Add(-16708, "jiong");
ht.Add(-16706, "jiu"); ht.Add(-16689, "ju"); ht.Add(-16664, "juan");
ht.Add(-16657, "jue"); ht.Add(-16647, "jun"); ht.Add(-16474, "ka");
ht.Add(-16470, "kai"); ht.Add(-16465, "kan"); ht.Add(-16459, "kang");
ht.Add(-16452, "kao"); ht.Add(-16448, "ke"); ht.Add(-16433, "ken");
ht.Add(-16429, "keng"); ht.Add(-16427, "kong"); ht.Add(-16423, "kou");
ht.Add(-16419, "ku"); ht.Add(-16412, "kua"); ht.Add(-16407, "kuai");
ht.Add(-16403, "kuan"); ht.Add(-16401, "kuang"); ht.Add(-16393, "kui");
ht.Add(-16220, "kun"); ht.Add(-16216, "kuo"); ht.Add(-16212, "la");
ht.Add(-16205, "lai"); ht.Add(-16202, "lan"); ht.Add(-16187, "lang");
ht.Add(-16180, "lao"); ht.Add(-16171, "le"); ht.Add(-16169, "lei");
ht.Add(-16158, "leng"); ht.Add(-16155, "li"); ht.Add(-15959, "lia");
ht.Add(-15958, "lian"); ht.Add(-15944, "liang"); ht.Add(-15933, "liao");
ht.Add(-15920, "lie"); ht.Add(-15915, "lin"); ht.Add(-15903, "ling");
ht.Add(-15889, "liu"); ht.Add(-15878, "long"); ht.Add(-15707, "lou");
ht.Add(-15701, "lu"); ht.Add(-15681, "lv"); ht.Add(-15667, "luan");
ht.Add(-15661, "lue"); ht.Add(-15659, "lun"); ht.Add(-15652, "luo");
ht.Add(-15640, "ma"); ht.Add(-15631, "mai"); ht.Add(-15625, "man");
ht.Add(-15454, "mang"); ht.Add(-15448, "mao"); ht.Add(-15436, "me");
ht.Add(-15435, "mei"); ht.Add(-15419, "men"); ht.Add(-15416, "meng");
ht.Add(-15408, "mi"); ht.Add(-15394, "mian"); ht.Add(-15385, "miao");
ht.Add(-15377, "mie"); ht.Add(-15375, "min"); ht.Add(-15369, "ming");
ht.Add(-15363, "miu"); ht.Add(-15362, "mo"); ht.Add(-15183, "mou");
ht.Add(-15180, "mu"); ht.Add(-15165, "na"); ht.Add(-15158, "nai");
ht.Add(-15153, "nan"); ht.Add(-15150, "nang"); ht.Add(-15149, "nao");
ht.Add(-15144, "ne"); ht.Add(-15143, "nei"); ht.Add(-15141, "nen");
ht.Add(-15140, "neng"); ht.Add(-15139, "ni"); ht.Add(-15128, "nian");
ht.Add(-15121, "niang"); ht.Add(-15119, "niao"); ht.Add(-15117, "nie");
ht.Add(-15110, "nin"); ht.Add(-15109, "ning"); ht.Add(-14941, "niu");
ht.Add(-14937, "nong"); ht.Add(-14933, "nu"); ht.Add(-14930, "nv");
ht.Add(-14929, "nuan"); ht.Add(-14928, "nue"); ht.Add(-14926, "nuo");
ht.Add(-14922, "o"); ht.Add(-14921, "ou"); ht.Add(-14914, "pa");
ht.Add(-14908, "pai"); ht.Add(-14902, "pan"); ht.Add(-14894, "pang");
ht.Add(-14889, "pao"); ht.Add(-14882, "pei"); ht.Add(-14873, "pen");
ht.Add(-14871, "peng"); ht.Add(-14857, "pi"); ht.Add(-14678, "pian");
ht.Add(-14674, "piao"); ht.Add(-14670, "pie"); ht.Add(-14668, "pin");
ht.Add(-14663, "ping"); ht.Add(-14654, "po"); ht.Add(-14645, "pu");
ht.Add(-14630, "qi"); ht.Add(-14594, "qia"); ht.Add(-14429, "qian");
ht.Add(-14407, "qiang"); ht.Add(-14399, "qiao"); ht.Add(-14384, "qie");
ht.Add(-14379, "qin"); ht.Add(-14368, "qing"); ht.Add(-14355, "qiong");
ht.Add(-14353, "qiu"); ht.Add(-14345, "qu"); ht.Add(-14170, "quan");
ht.Add(-14159, "que"); ht.Add(-14151, "qun"); ht.Add(-14149, "ran");
ht.Add(-14145, "rang"); ht.Add(-14140, "rao"); ht.Add(-14137, "re");
ht.Add(-14135, "ren"); ht.Add(-14125, "reng"); ht.Add(-14123, "ri");
ht.Add(-14122, "rong"); ht.Add(-14112, "rou"); ht.Add(-14109, "ru");
ht.Add(-14099, "ruan"); ht.Add(-14097, "rui"); ht.Add(-14094, "run");
ht.Add(-14092, "ruo"); ht.Add(-14090, "sa"); ht.Add(-14087, "sai");
ht.Add(-14083, "san"); ht.Add(-13917, "sang"); ht.Add(-13914, "sao");
ht.Add(-13910, "se"); ht.Add(-13907, "sen"); ht.Add(-13906, "seng");
ht.Add(-13905, "sha"); ht.Add(-13896, "shai"); ht.Add(-13894, "shan");
ht.Add(-13878, "shang"); ht.Add(-13870, "shao"); ht.Add(-13859, "she");
ht.Add(-13847, "shen"); ht.Add(-13831, "sheng"); ht.Add(-13658, "shi");
ht.Add(-13611, "shou"); ht.Add(-13601, "shu"); ht.Add(-13406, "shua");
ht.Add(-13404, "shuai"); ht.Add(-13400, "shuan"); ht.Add(-13398, "shuang");
ht.Add(-13395, "shui"); ht.Add(-13391, "shun"); ht.Add(-13387, "shuo");
ht.Add(-13383, "si"); ht.Add(-13367, "song"); ht.Add(-13359, "sou");
ht.Add(-13356, "su"); ht.Add(-13343, "suan"); ht.Add(-13340, "sui");
ht.Add(-13329, "sun"); ht.Add(-13326, "suo"); ht.Add(-13318, "ta");
ht.Add(-13147, "tai"); ht.Add(-13138, "tan"); ht.Add(-13120, "tang");
ht.Add(-13107, "tao"); ht.Add(-13096, "te"); ht.Add(-13095, "teng");
ht.Add(-13091, "ti"); ht.Add(-13076, "tian"); ht.Add(-13068, "tiao");
ht.Add(-13063, "tie"); ht.Add(-13060, "ting"); ht.Add(-12888, "tong");
ht.Add(-12875, "tou"); ht.Add(-12871, "tu"); ht.Add(-12860, "tuan");
ht.Add(-12858, "tui"); ht.Add(-12852, "tun"); ht.Add(-12849, "tuo");
ht.Add(-12838, "wa"); ht.Add(-12831, "wai"); ht.Add(-12829, "wan");
ht.Add(-12812, "wang"); ht.Add(-12802, "wei"); ht.Add(-12607, "wen");
ht.Add(-12597, "weng"); ht.Add(-12594, "wo"); ht.Add(-12585, "wu");
ht.Add(-12556, "xi"); ht.Add(-12359, "xia"); ht.Add(-12346, "xian");
ht.Add(-12320, "xiang"); ht.Add(-12300, "xiao"); ht.Add(-12120, "xie");
ht.Add(-12099, "xin"); ht.Add(-12089, "xing"); ht.Add(-12074, "xiong");
ht.Add(-12067, "xiu"); ht.Add(-12058, "xu"); ht.Add(-12039, "xuan");
ht.Add(-11867, "xue"); ht.Add(-11861, "xun"); ht.Add(-11847, "ya");
ht.Add(-11831, "yan"); ht.Add(-11798, "yang"); ht.Add(-11781, "yao");
ht.Add(-11604, "ye"); ht.Add(-11589, "yi"); ht.Add(-11536, "yin");
ht.Add(-11358, "ying"); ht.Add(-11340, "yo"); ht.Add(-11339, "yong");
ht.Add(-11324, "you"); ht.Add(-11303, "yu"); ht.Add(-11097, "yuan");
ht.Add(-11077, "yue"); ht.Add(-11067, "yun"); ht.Add(-11055, "za");
ht.Add(-11052, "zai"); ht.Add(-11045, "zan"); ht.Add(-11041, "zang");
ht.Add(-11038, "zao"); ht.Add(-11024, "ze"); ht.Add(-11020, "zei");
ht.Add(-11019, "zen"); ht.Add(-11018, "zeng"); ht.Add(-11014, "zha");
ht.Add(-10838, "zhai"); ht.Add(-10832, "zhan"); ht.Add(-10815, "zhang");
ht.Add(-10800, "zhao"); ht.Add(-10790, "zhe"); ht.Add(-10780, "zhen");
ht.Add(-10764, "zheng"); ht.Add(-10587, "zhi"); ht.Add(-10544, "zhong");
ht.Add(-10533, "zhou"); ht.Add(-10519, "zhu"); ht.Add(-10331, "zhua");
ht.Add(-10329, "zhuai"); ht.Add(-10328, "zhuan"); ht.Add(-10322, "zhuang");
ht.Add(-10315, "zhui"); ht.Add(-10309, "zhun"); ht.Add(-10307, "zhuo");
ht.Add(-10296, "zi"); ht.Add(-10281, "zong"); ht.Add(-10274, "zou");
ht.Add(-10270, "zu"); ht.Add(-10262, "zuan"); ht.Add(-10260, "zui");
ht.Add(-10256, "zun"); ht.Add(-10254, "zuo"); ht.Add(-10247, "zz");
return ht;
}
}
}
第三种方法:
其实现的原理就是先将汉字转化成为内码,然后通过内码和拼音的对照来查找。
public class chs2py {/**//// <summary> ///将汉字转换成为拼音 ///作者: ///完成于: /// </summary> private static int[] pyvalue=new int[]{-20319,-20317,-20304,-20295,-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036,-20032,-20026, -20002,-19990,-19986,-19982,-19976,-19805,-19784,-19775,-19774,-19763,-19756,-19751,-19746,-19741,-19739,-19728, -19725,-19715,-19540,-19531,-19525,-19515,-19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,-19270,-19263, -19261,-19249,-19243,-19242,-19238,-19235,-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006,-19003,-18996, -18977,-18961,-18952,-18783,-18774,-18773,-18763,-18756,-18741,-18735,-18731,-18722,-18710,-18697,-18696,-18526, -18518,-18501,-18490,-18478,-18463,-18448,-18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,-18184,-18183, -18181,-18012,-17997,-17988,-17970,-17964,-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752,-17733,-17730, -17721,-17703,-17701,-17697,-17692,-17683,-17676,-17496,-17487,-17482,-17468,-17454,-17433,-17427,-17417,-17202, -17185,-16983,-16970,-16942,-16915,-16733,-16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,-16465,-16459, -16452,-16448,-16433,-16429,-16427,-16423,-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216,-16212,-16205, -16202,-16187,-16180,-16171,-16169,-16158,-16155,-15959,-15958,-15944,-15933,-15920,-15915,-15903,-15889,-15878, -15707,-15701,-15681,-15667,-15661,-15659,-15652,-15640,-15631,-15625,-15454,-15448,-15436,-15435,-15419,-15416, -15408,-15394,-15385,-15377,-15375,-15369,-15363,-15362,-15183,-15180,-15165,-15158,-15153,-15150,-15149,-15144, -15143,-15141,-15140,-15139,-15128,-15121,-15119,-15117,-15110,-15109,-14941,-14937,-14933,-14930,-14929,-14928, -14926,-14922,-14921,-14914,-14908,-14902,-14894,-14889,-14882,-14873,-14871,-14857,-14678,-14674,-14670,-14668, -14663,-14654,-14645,-14630,-14594,-14429,-14407,-14399,-14384,-14379,-14368,-14355,-14353,-14345,-14170,-14159, -14151,-14149,-14145,-14140,-14137,-14135,-14125,-14123,-14122,-14112,-14109,-14099,-14097,-14094,-14092,-14090, -14087,-14083,-13917,-13914,-13910,-13907,-13906,-13905,-13896,-13894,-13878,-13870,-13859,-13847,-13831,-13658, -13611,-13601,-13406,-13404,-13400,-13398,-13395,-13391,-13387,-13383,-13367,-13359,-13356,-13343,-13340,-13329, -13326,-13318,-13147,-13138,-13120,-13107,-13096,-13095,-13091,-13076,-13068,-13063,-13060,-12888,-12875,-12871, -12860,-12858,-12852,-12849,-12838,-12831,-12829,-12812,-12802,-12607,-12597,-12594,-12585,-12556,-12359,-12346, -12320,-12300,-12120,-12099,-12089,-12074,-12067,-12058,-12039,-11867,-11861,-11847,-11831,-11798,-11781,-11604, -11589,-11536,-11358,-11340,-11339,-11324,-11303,-11097,-11077,-11067,-11055,-11052,-11045,-11041,-11038,-11024, -11020,-11019,-11018,-11014,-10838,-10832,-10815,-10800,-10790,-10780,-10764,-10587,-10544,-10533,-10519,-10331, -10329,-10328,-10322,-10315,-10309,-10307,-10296,-10281,-10274,-10270,-10262,-10260,-10256,-10254}; private static string[] pystr=new string[]{"a","ai","an","ang","ao","ba","bai","ban","bang","bao","bei","ben","beng","bi","bian","biao", "bie","bin","bing","bo","bu","ca","cai","can","cang","cao","ce","ceng","cha","chai","chan","chang","chao","che","chen", "cheng","chi","chong","chou","chu","chuai","chuan","chuang","chui","chun","chuo","ci","cong","cou","cu","cuan","cui", "cun","cuo","da","dai","dan","dang","dao","de","deng","di","dian","diao","die","ding","diu","dong","dou","du","duan", "dui","dun","duo","e","en","er","fa","fan","fang","fei","fen","feng","fo","fou","fu","ga","gai","gan","gang","gao", "ge","gei","gen","geng","gong","gou","gu","gua","guai","guan","guang","gui","gun","guo","ha","hai","han","hang", "hao","he","hei","hen","heng","hong","hou","hu","hua","huai","huan","huang","hui","hun","huo","ji","jia","jian", "jiang","jiao","jie","jin","jing","jiong","jiu","ju","juan","jue","jun","ka","kai","kan","kang","kao","ke","ken", "keng","kong","kou","ku","kua","kuai","kuan","kuang","kui","kun","kuo","la","lai","lan","lang","lao","le","lei", "leng","li","lia","lian","liang","liao","lie","lin","ling","liu","long","lou","lu","lv","luan","lue","lun","luo", "ma","mai","man","mang","mao","me","mei","men","meng","mi","mian","miao","mie","min","ming","miu","mo","mou","mu", "na","nai","nan","nang","nao","ne","nei","nen","neng","ni","nian","niang","niao","nie","nin","ning","niu","nong", "nu","nv","nuan","nue","nuo","o","ou","pa","pai","pan","pang","pao","pei","pen","peng","pi","pian","piao","pie", "pin","ping","po","pu","qi","qia","qian","qiang","qiao","qie","qin","qing","qiong","qiu","qu","quan","que","qun", "ran","rang","rao","re","ren","reng","ri","rong","rou","ru","ruan","rui","run","ruo","sa","sai","san","sang", "sao","se","sen","seng","sha","shai","shan","shang","shao","she","shen","sheng","shi","shou","shu","shua", "shuai","shuan","shuang","shui","shun","shuo","si","song","sou","su","suan","sui","sun","suo","ta","tai", "tan","tang","tao","te","teng","ti","tian","tiao","tie","ting","tong","tou","tu","tuan","tui","tun","tuo", "wa","wai","wan","wang","wei","wen","weng","wo","wu","xi","xia","xian","xiang","xiao","xie","xin","xing", "xiong","xiu","xu","xuan","xue","xun","ya","yan","yang","yao","ye","yi","yin","ying","yo","yong","you", "yu","yuan","yue","yun","za","zai","zan","zang","zao","ze","zei","zen","zeng","zha","zhai","zhan","zhang", "zhao","zhe","zhen","zheng","zhi","zhong","zhou","zhu","zhua","zhuai","zhuan","zhuang","zhui","zhun","zhuo", "zi","zong","zou","zu","zuan","zui","zun","zuo"}; public chs2py() { // // TODO: 在此处添加构造函数逻辑 // } public static string convert(string chrstr) { byte[] array = new byte[2]; string returnstr=""; int chrasc=0; int i1 = 0; int i2 =0; char[] nowchar=chrstr.ToCharArray(); for (int j=0;j<nowchar.Length ;j++) { array = System.Text.Encoding.Default.GetBytes(nowchar[j].ToString ()); i1 = (short)(array[0] ); i2 = (short)(array[1] ); chrasc=i1*256+i2-65536; if (chrasc>0 && chrasc<160) { returnstr+=nowchar[j]; } else { for (int i=(pyvalue.Length -1);i>=0;i--) { if (pyvalue[i]<=chrasc) { returnstr+=pystr[i]; break; } } } } return returnstr; } }
一些基本扩展
private void button5_Click(object sender, System.EventArgs e) { byte[] myByte = System.Text.Encoding.Default.GetBytes(this.textBox1.Text); int i = myByte.Length; string str_temp=this.textBox1.Text; string str_target=""; if(i == this.textBox1.Text.Length) { MessageBox.Show("没有汉字"); } else { MessageBox.Show("有汉字"); //有汉字将进行解析 for (int j=0;j<str_temp.Length;j++) { if (str_temp[j]>128) { //是汉字 str_target+=chs2py.convert(str_temp[j].ToString())+" "; } else { str_target+=str_temp[j].ToString(); } } } textBox2.Text=str_target; }
其中
byte[] myByte = System.Text.Encoding.Default.GetBytes(this.textBox1.Text); int i = myByte.Length; if(i == this.textBox1.Text.Length) { //没有汉字 } else { //有汉字 }
第四种方法:
在WINDOWS 下是好的 但是程序要在 LINUX 下运行,就不行了,请问这个该怎么解决?
Code :
/**
* 返回字符串的全拼,是汉字转化为全拼,其它字符不进行转换
* @param cnStr String
* 字符串
* @return String
* 转换成全拼后的字符串
*/
public static String getFullSpell(String cnStr)
{
if(null == cnStr || "".equals(cnStr.trim())){
return cnStr;
}
char[] chars = cnStr.toCharArray();
StringBuffer retuBuf = new StringBuffer();
for(int i = 0,Len = chars.length;i < Len;i++){
int ascii = getCnAscii(chars[i]);
if(ascii == 0){ //取ascii时出错
retuBuf.append(chars[i]);
}
else{
String spell = getSpellByAscii(ascii);
if(spell == null){
retuBuf.append(chars[i]);
}
else{
retuBuf.append(spell);
} // end of if spell == null
} // end of if ascii <= -20400
} // end of for
return retuBuf.toString();
}
/**
* 获得单个汉字的Ascii.
* @param cn char
* 汉字字符
* @return int
* 错误返回 0,否则返回ascii
*/
public static int getCnAscii(char cn)
{
byte[] bytes = (String.valueOf(cn)).getBytes();
if(bytes == null || bytes.length > 2 || bytes.length <= 0){ //错误
return 0;
}
if(bytes.length == 1){ //英文字符
return bytes[0];
}
if(bytes.length == 2){ //中文字符
int hightByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
int ascii = (256 * hightByte + lowByte) - 256 * 256;
//System.out.println("ASCII=" + ascii);
return ascii;
}
return 0; //错误
}
/**
* 根据ASCII码到SpellMap中查找对应的拼音
* @param ascii int
* 字符对应的ASCII
* @return String
* 拼音,首先判断ASCII是否>0&<160,如果是返回对应的字符,
*
否则到SpellMap中查找,如果没有找到拼音,则返回null,如果找到则返回拼音.
*/
public static String getSpellByAscii(int ascii)
{
if(ascii > 0 && ascii < 160){ //单字符
return String.valueOf((char)ascii);
}
if(ascii < -20319 || ascii > -10247){ //不知道的字符
return null;
}
Set keySet = spellMap.keySet();
Iterator it = keySet.iterator();
String spell0 = null;;
String spell = null;
int asciiRang0 = -20319;
int asciiRang;
while(it.hasNext()){
spell = (String)it.next();
Object valObj = spellMap.get(spell);
if(valObj instanceof Integer){
asciiRang = ((Integer)valObj).intValue();
if(ascii >= asciiRang0 && ascii < asciiRang){ //区间找到
return(spell0 == null) ? spell : spell0;
}
else{
spell0 = spell;
asciiRang0 = asciiRang;
}
}
}
return null;
}
static
{
if(spellMap == null){
spellMap = new LinkedHashMap(400);
}
initialize();
System.out.println("Chinese transfer Spell Done.");
}
private static void spellPut(String spell,int ascii)
{
spellMap.put(spell,new Integer(ascii));
}
private static void initialize()
{
spellPut("a", -20319);
spellPut("ai", -20317);
spellPut("an", -20304);
spellPut("ang", -20295);
spellPut("ao", -20292);
spellPut("ba", -20283);
spellPut("bai", -20265);
spellPut("ban", -20257);
spellPut("bang", -20242);
spellPut("bao", -20230);
spellPut("bei", -20051);
spellPut("ben", -20036);
spellPut("beng", -20032);
spellPut("bi", -20026);
spellPut("bian", -20002);
spellPut("biao", -19990);
spellPut("bie", -19986);
spellPut("bin", -19982);
spellPut("bing", -19976);
spellPut("bo", -19805);
spellPut("bu", -19784);
spellPut("ca", -19775);
spellPut("cai", -19774);
spellPut("can", -19763);
spellPut("cang", -19756);
spellPut("cao", -19751);
spellPut("ce", -19746);
spellPut("ceng", -19741);
spellPut("cha", -19739);
spellPut("chai", -19728);
spellPut("chan", -19725);
spellPut("chang", -19715);
spellPut("chao", -19540);
spellPut("che", -19531);
spellPut("chen", -19525);
spellPut("cheng", -19515);
spellPut("chi", -19500);
spellPut("chong", -19484);
spellPut("chou", -19479);
spellPut("chu", -19467);
spellPut("chuai", -19289);
spellPut("chuan", -19288);
spellPut("chuang", -19281);
spellPut("chui", -19275);
spellPut("chun", -19270);
spellPut("chuo", -19263);
spellPut("ci", -19261);
spellPut("cong", -19249);
spellPut("cou", -19243);
spellPut("cu", -19242);
spellPut("cuan", -19238);
spellPut("cui", -19235);
spellPut("cun", -19227);
spellPut("cuo", -19224);
spellPut("da", -19218);
spellPut("dai", -19212);
spellPut("dan", -19038);
spellPut("dang", -19023);
spellPut("dao", -19018);
spellPut("de", -19006);
spellPut("deng", -19003);
spellPut("di", -18996);
spellPut("dian", -18977);
spellPut("diao", -18961);
spellPut("die", -18952);
spellPut("ding", -18783);
spellPut("diu", -18774);
spellPut("dong", -18773);
spellPut("dou", -18763);
spellPut("du", -18756);
spellPut("duan", -18741);
spellPut("dui", -18735);
spellPut("dun", -18731);
spellPut("duo", -18722);
spellPut("e", -18710);
spellPut("en", -18697);
spellPut("er", -18696);
spellPut("fa", -18526);
spellPut("fan", -18518);
spellPut("fang", -18501);
spellPut("fei", -18490);
spellPut("fen", -18478);
spellPut("feng", -18463);
spellPut("fo", -18448);
spellPut("fou", -18447);
spellPut("fu", -18446);
spellPut("ga", -18239);
spellPut("gai", -18237);
spellPut("gan", -18231);
spellPut("gang", -18220);
spellPut("gao", -18211);
spellPut("ge", -18201);
spellPut("gei", -18184);
spellPut("gen", -18183);
spellPut("geng", -18181);
spellPut("gong", -18012);
spellPut("gou", -17997);
spellPut("gu", -17988);
spellPut("gua", -17970);
spellPut("guai", -17964);
spellPut("guan", -17961);
spellPut("guang", -17950);
spellPut("gui", -17947);
spellPut("gun", -17931);
spellPut("guo", -17928);
spellPut("ha", -17922);
spellPut("hai", -17759);
spellPut("han", -17752);
spellPut("hang", -17733);
spellPut("hao", -17730);
spellPut("he", -17721);
spellPut("hei", -17703);
spellPut("hen", -17701);
spellPut("heng", -17697);
spellPut("hong", -17692);
spellPut("hou", -17683);
spellPut("hu", -17676);
spellPut("hua", -17496);
spellPut("huai", -17487);
spellPut("huan", -17482);
spellPut("huang", -17468);
spellPut("hui", -17454);
spellPut("hun", -17433);
spellPut("huo", -17427);
spellPut("ji", -17417);
spellPut("jia", -17202);
spellPut("jian", -17185);
spellPut("jiang", -16983);
spellPut("jiao", -16970);
spellPut("jie", -16942);
spellPut("jin", -16915);
spellPut("jing", -16733);
spellPut("jiong", -16708);
spellPut("jiu", -16706);
spellPut("ju", -16689);
spellPut("juan", -16664);
spellPut("jue", -16657);
spellPut("jun", -16647);
spellPut("ka", -16474);
spellPut("kai", -16470);
spellPut("kan", -16465);
spellPut("kang", -16459);
spellPut("kao", -16452);
spellPut("ke", -16448);
spellPut("ken", -16433);
spellPut("keng", -16429);
spellPut("kong", -16427);
spellPut("kou", -16423);
spellPut("ku", -16419);
spellPut("kua", -16412);
spellPut("kuai", -16407);
spellPut("kuan", -16403);
spellPut("kuang", -16401);
spellPut("kui", -16393);
spellPut("kun", -16220);
spellPut("kuo", -16216);
spellPut("la", -16212);
spellPut("lai", -16205);
spellPut("lan", -16202);
spellPut("lang", -16187);
spellPut("lao", -16180);
spellPut("le", -16171);
spellPut("lei", -16169);
spellPut("leng", -16158);
spellPut("li", -16155);
spellPut("lia", -15959);
spellPut("lian", -15958);
spellPut("liang", -15944);
spellPut("liao", -15933);
spellPut("lie", -15920);
spellPut("lin", -15915);
spellPut("ling", -15903);
spellPut("liu", -15889);
spellPut("long", -15878);
spellPut("lou", -15707);
spellPut("lu", -15701);
spellPut("lv", -15681);
spellPut("luan", -15667);
spellPut("lue", -15661);
spellPut("lun", -15659);
spellPut("luo", -15652);
spellPut("ma", -15640);
spellPut("mai", -15631);
spellPut("man", -15625);
spellPut("mang", -15454);
spellPut("mao", -15448);
spellPut("me", -15436);
spellPut("mei", -15435);
spellPut("men", -15419);
spellPut("meng", -15416);
spellPut("mi", -15408);
spellPut("mian", -15394);
spellPut("miao", -15385);
spellPut("mie", -15377);
spellPut("min", -15375);
spellPut("ming", -15369);
spellPut("miu", -15363);
spellPut("mo", -15362);
spellPut("mou", -15183);
spellPut("mu", -15180);
spellPut("na", -15165);
spellPut("nai", -15158);
spellPut("nan", -15153);
spellPut("nang", -15150);
spellPut("nao", -15149);
spellPut("ne", -15144);
spellPut("nei", -15143);
spellPut("nen", -15141);
spellPut("neng", -15140);
spellPut("ni", -15139);
spellPut("nian", -15128);
spellPut("niang", -15121);
spellPut("niao", -15119);
spellPut("nie", -15117);
spellPut("nin", -15110);
spellPut("ning", -15109);
spellPut("niu", -14941);
spellPut("nong", -14937);
spellPut("nu", -14933);
spellPut("nv", -14930);
spellPut("nuan", -14929);
spellPut("nue", -14928);
spellPut("nuo", -14926);
spellPut("o", -14922);
spellPut("ou", -14921);
spellPut("pa", -14914);
spellPut("pai", -14908);
spellPut("pan", -14902);
spellPut("pang", -14894);
spellPut("pao", -14889);
spellPut("pei", -14882);
spellPut("pen", -14873);
spellPut("peng", -14871);
spellPut("pi", -14857);
spellPut("pian", -14678);
spellPut("piao", -14674);
spellPut("pie", -14670);
spellPut("pin", -14668);
spellPut("ping", -14663);
spellPut("po", -14654);
spellPut("pu", -14645);
spellPut("qi", -14630);
spellPut("qia", -14594);
spellPut("qian", -14429);
spellPut("qiang", -14407);
spellPut("qiao", -14399);
spellPut("qie", -14384);
spellPut("qin", -14379);
spellPut("qing", -14368);
spellPut("qiong", -14355);
spellPut("qiu", -14353);
spellPut("qu", -14345);
spellPut("quan", -14170);
spellPut("que", -14159);
spellPut("qun", -14151);
spellPut("ran", -14149);
spellPut("rang", -14145);
spellPut("rao", -14140);
spellPut("re", -14137);
spellPut("ren", -14135);
spellPut("reng", -14125);
spellPut("ri", -14123);
spellPut("rong", -14122);
spellPut("rou", -14112);
spellPut("ru", -14109);
spellPut("ruan", -14099);
spellPut("rui", -14097);
spellPut("run", -14094);
spellPut("ruo", -14092);
spellPut("sa", -14090);
spellPut("sai", -14087);
spellPut("san", -14083);
spellPut("sang", -13917);
spellPut("sao", -13914);
spellPut("se", -13910);
spellPut("sen", -13907);
spellPut("seng", -13906);
spellPut("sha", -13905);
spellPut("shai", -13896);
spellPut("shan", -13894);
spellPut("shang", -13878);
spellPut("shao", -13870);
spellPut("she", -13859);
spellPut("shen", -13847);
spellPut("sheng", -13831);
spellPut("shi", -13658);
spellPut("shou", -13611);
spellPut("shu", -13601);
spellPut("shua", -13406);
spellPut("shuai", -13404);
spellPut("shuan", -13400);
spellPut("shuang", -13398);
spellPut("shui", -13395);
spellPut("shun", -13391);
spellPut("shuo", -13387);
spellPut("si", -13383);
spellPut("song", -13367);
spellPut("sou", -13359);
spellPut("su", -13356);
spellPut("suan", -13343);
spellPut("sui", -13340);
spellPut("sun", -13329);
spellPut("suo", -13326);
spellPut("ta", -13318);
spellPut("tai", -13147);
spellPut("tan", -13138);
spellPut("tang", -13120);
spellPut("tao", -13107);
spellPut("te", -13096);
spellPut("teng", -13095);
spellPut("ti", -13091);
spellPut("tian", -13076);
spellPut("tiao", -13068);
spellPut("tie", -13063);
spellPut("ting", -13060);
spellPut("tong", -12888);
spellPut("tou", -12875);
spellPut("tu", -12871);
spellPut("tuan", -12860);
spellPut("tui", -12858);
spellPut("tun", -12852);
spellPut("tuo", -12849);
spellPut("wa", -12838);
spellPut("wai", -12831);
spellPut("wan", -12829);
spellPut("wang", -12812);
spellPut("wei", -12802);
spellPut("wen", -12607);
spellPut("weng", -12597);
spellPut("wo", -12594);
spellPut("wu", -12585);
spellPut("xi", -12556);
spellPut("xia", -12359);
spellPut("xian", -12346);
spellPut("xiang", -12320);
spellPut("xiao", -12300);
spellPut("xie", -12120);
spellPut("xin", -12099);
spellPut("xing", -12089);
spellPut("xiong", -12074);
spellPut("xiu", -12067);
spellPut("xu", -12058);
spellPut("xuan", -12039);
spellPut("xue", -11867);
spellPut("xun", -11861);
spellPut("ya", -11847);
spellPut("yan", -11831);
spellPut("yang", -11798);
spellPut("yao", -11781);
spellPut("ye", -11604);
spellPut("yi", -11589);
spellPut("yin", -11536);
spellPut("ying", -11358);
spellPut("yo", -11340);
spellPut("yong", -11339);
spellPut("you", -11324);
spellPut("yu", -11303);
spellPut("yuan", -11097);
spellPut("yue", -11077);
spellPut("yun", -11067);
spellPut("za", -11055);
spellPut("zai", -11052);
spellPut("zan", -11045);
spellPut("zang", -11041);
spellPut("zao", -11038);
spellPut("ze", -11024);
spellPut("zei", -11020);
spellPut("zen", -11019);
spellPut("zeng", -11018);
spellPut("zha", -11014);
spellPut("zhai", -10838);
spellPut("zhan", -10832);
spellPut("zhang", -10815);
spellPut("zhao", -10800);
spellPut("zhe", -10790);
spellPut("zhen", -10780);
spellPut("zheng", -10764);
spellPut("zhi", -10587);
spellPut("zhong", -10544);
spellPut("zhou", -10533);
spellPut("zhu", -10519);
spellPut("zhua", -10331);
spellPut("zhuai", -10329);
spellPut("zhuan", -10328);
spellPut("zhuang", -10322);
spellPut("zhui", -10315);
spellPut("zhun", -10309);
spellPut("zhuo", -10307);
spellPut("zi", -10296);
spellPut("zong", -10281);
spellPut("zou", -10274);
spellPut("zu", -10270);
spellPut("zuan", -10262);
spellPut("zui", -10260);
spellPut("zun", -10256);
spellPut("zuo", -10254);
}
第五种方法:
/// <summary>
/// 把汉字转换成拼音(全拼)
/// </summary>
/// <param name="hzString">汉字字符串</param>
/// <returns>转换后的拼音(全拼)字符串</returns>
public static string ConvertE(string hzString)
{
// 匹配中文字符
Regex regex = new Regex("^[\u4e00-\u9fa5]$");
byte[] array = new byte[2];
string pyString = "";
int chrAsc = 0;
int i1 = 0;
int i2 = 0;
char[] noWChar = hzString.ToCharArray();
for (int j = 0; j < noWChar.Length; j++)
{
// 中文字符
if (regex.IsMatch(noWChar[j].ToString()))
{
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
i1 = (short)(array[0]);
i2 = (short)(array[1]);
chrAsc = i1 * 256 + i2 - 65536;
if (chrAsc > 0 && chrAsc < 160)
{
pyString += noWChar[j];
}
else
{
// 修正部分文字
if (chrAsc == -9254) // 修正“圳”字
pyString += "Zhen";
else
{
for (int i = (pyValue.Length - 1); i >= 0; i--)
{
if (pyValue[i] <= chrAsc)
{
pyString += pyName[i];
break;
}
}
}
}
}
// 非中文字符
else
{
pyString += noWChar[j].ToString();
}
}
return pyString;
}
#region 把汉字转化成全拼音
private static int[] pyValue = new int[]
{
-20319,-20317,-20304,-20295,-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036,
-20032,-20026,-20002,-19990,-19986,-19982,-19976,-19805,-19784,-19775,-19774,-19763,
-19756,-19751,-19746,-19741,-19739,-19728,-19725,-19715,-19540,-19531,-19525,-19515,
-19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,-19270,-19263,-19261,-19249,
-19243,-19242,-19238,-19235,-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006,
-19003,-18996,-18977,-18961,-18952,-18783,-18774,-18773,-18763,-18756,-18741,-18735,
-18731,-18722,-18710,-18697,-18696,-18526,-18518,-18501,-18490,-18478,-18463,-18448,
-18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,-18184,-18183, -18181,-18012,
-17997,-17988,-17970,-17964,-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752,
-17733,-17730,-17721,-17703,-17701,-17697,-17692,-17683,-17676,-17496,-17487,-17482,
-17468,-17454,-17433,-17427,-17417,-17202,-17185,-16983,-16970,-16942,-16915,-16733,
-16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,-16465,-16459,-16452,-16448,
-16433,-16429,-16427,-16423,-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216,
-16212,-16205,-16202,-16187,-16180,-16171,-16169,-16158,-16155,-15959,-15958,-15944,
-15933,-15920,-15915,-15903,-15889,-15878,-15707,-15701,-15681,-15667,-15661,-15659,
-15652,-15640,-15631,-15625,-15454,-15448,-15436,-15435,-15419,-15416,-15408,-15394,
-15385,-15377,-15375,-15369,-15363,-15362,-15183,-15180,-15165,-15158,-15153,-15150,
-15149,-15144,-15143,-15141,-15140,-15139,-15128,-15121,-15119,-15117,-15110,-15109,
-14941,-14937,-14933,-14930,-14929,-14928,-14926,-14922,-14921,-14914,-14908,-14902,
-14894,-14889,-14882,-14873,-14871,-14857,-14678,-14674,-14670,-14668,-14663,-14654,
-14645,-14630,-14594,-14429,-14407,-14399,-14384,-14379,-14368,-14355,-14353,-14345,
-14170,-14159,-14151,-14149,-14145,-14140,-14137,-14135,-14125,-14123,-14122,-14112,
-14109,-14099,-14097,-14094,-14092,-14090,-14087,-14083,-13917,-13914,-13910,-13907,
-13906,-13905,-13896,-13894,-13878,-13870,-13859,-13847,-13831,-13658,-13611,-13601,
-13406,-13404,-13400,-13398,-13395,-13391,-13387,-13383,-13367,-13359,-13356,-13343,
-13340,-13329,-13326,-13318,-13147,-13138,-13120,-13107,-13096,-13095,-13091,-13076,
-13068,-13063,-13060,-12888,-12875,-12871,-12860,-12858,-12852,-12849,-12838,-12831,
-12829,-12812,-12802,-12607,-12597,-12594,-12585,-12556,-12359,-12346,-12320,-12300,
-12120,-12099,-12089,-12074,-12067,-12058,-12039,-11867,-11861,-11847,-11831,-11798,
-11781,-11604,-11589,-11536,-11358,-11340,-11339,-11324,-11303,-11097,-11077,-11067,
-11055,-11052,-11045,-11041,-11038,-11024,-11020,-11019,-11018,-11014,-10838,-10832,
-10815,-10800,-10790,-10780,-10764,-10587,-10544,-10533,-10519,-10331,-10329,-10328,
-10322,-10315,-10309,-10307,-10296,-10281,-10274,-10270,-10262,-10260,-10256,-10254
};
private static string[] pyName = new string[]
{
"A","Ai","An","Ang","Ao","Ba","Bai","Ban","Bang","Bao","Bei","Ben",
"Beng","Bi","Bian","Biao","Bie","Bin","Bing","Bo","Bu","Ba","Cai","Can",
"Cang","Cao","Ce","Ceng","Cha","Chai","Chan","Chang","Chao","Che","Chen","Cheng",
"Chi","Chong","Chou","Chu","Chuai","Chuan","Chuang","Chui","Chun","Chuo","Ci","Cong",
"Cou","Cu","Cuan","Cui","Cun","Cuo","Da","Dai","Dan","Dang","Dao","De",
"Deng","Di","Dian","Diao","Die","Ding","Diu","Dong","Dou","Du","Duan","Dui",
"Dun","Duo","E","En","Er","Fa","Fan","Fang","Fei","Fen","Feng","Fo",
"Fou","Fu","Ga","Gai","Gan","Gang","Gao","Ge","Gei","Gen","Geng","Gong",
"Gou","Gu","Gua","Guai","Guan","Guang","Gui","Gun","Guo","Ha","Hai","Han",
"Hang","Hao","He","Hei","Hen","Heng","Hong","Hou","Hu","Hua","Huai","Huan",
"Huang","Hui","Hun","Huo","Ji","Jia","Jian","Jiang","Jiao","Jie","Jin","Jing",
"Jiong","Jiu","Ju","Juan","Jue","Jun","Ka","Kai","Kan","Kang","Kao","Ke",
"Ken","Keng","Kong","Kou","Ku","Kua","Kuai","Kuan","Kuang","Kui","Kun","Kuo",
"La","Lai","Lan","Lang","Lao","Le","Lei","Leng","Li","Lia","Lian","Liang",
"Liao","Lie","Lin","Ling","Liu","Long","Lou","Lu","Lv","Luan","Lue","Lun",
"Luo","Ma","Mai","Man","Mang","Mao","Me","Mei","Men","Meng","Mi","Mian",
"Miao","Mie","Min","Ming","Miu","Mo","Mou","Mu","Na","Nai","Nan","Nang",
"Nao","Ne","Nei","Nen","Neng","Ni","Nian","Niang","Niao","Nie","Nin","Ning",
"Niu","Nong","Nu","Nv","Nuan","Nue","Nuo","O","Ou","Pa","Pai","Pan",
"Pang","Pao","Pei","Pen","Peng","Pi","Pian","Piao","Pie","Pin","Ping","Po",
"Pu","Qi","Qia","Qian","Qiang","Qiao","Qie","Qin","Qing","Qiong","Qiu","Qu",
"Quan","Que","Qun","Ran","Rang","Rao","Re","Ren","Reng","Ri","Rong","Rou",
"Ru","Ruan","Rui","Run","Ruo","Sa","Sai","San","Sang","Sao","Se","Sen",
"Seng","Sha","Shai","Shan","Shang","Shao","She","Shen","Sheng","Shi","Shou","Shu",
"Shua","Shuai","Shuan","Shuang","Shui","Shun","Shuo","Si","Song","Sou","Su","Suan",
"Sui","Sun","Suo","Ta","Tai","Tan","Tang","Tao","Te","Teng","Ti","Tian",
"Tiao","Tie","Ting","Tong","Tou","Tu","Tuan","Tui","Tun","Tuo","Wa","Wai",
"Wan","Wang","Wei","Wen","Weng","Wo","Wu","Xi","Xia","Xian","Xiang","Xiao",
"Xie","Xin","Xing","Xiong","Xiu","Xu","Xuan","Xue","Xun","Ya","Yan","Yang",
"Yao","Ye","Yi","Yin","Ying","Yo","Yong","You","Yu","Yuan","Yue","Yun",
"Za", "Zai","Zan","Zang","Zao","Ze","Zei","Zen","Zeng","Zha","Zhai","Zhan",
"Zhang","Zhao","Zhe","Zhen","Zheng","Zhi","Zhong","Zhou","Zhu","Zhua","Zhuai","Zhuan",
"Zhuang","Zhui","Zhun","Zhuo","Zi","Zong","Zou","Zu","Zuan","Zui","Zun","Zuo"
};
#endregion
原文:http://www.cnblogs.com/yaqigame/p/4336047.html