/**SunriseSpell-AChinesepinyinlibrary**Copyright(C)2004micmic4free@hotmail.com**Thisprogramisfreesoftware;youcanredistributeitand/ormodify*itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby*theFreeSoftwareFoundation;eitherversion2oftheLicense,or*(atyouroption)anylaterversion.**Thisprogramisdistributedinthehopethatitwillbeuseful,*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe*GNUGeneralPublicLicenseformoredetails.**YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense*alongwiththisprogram;ifnot,writetotheFreeSoftware*Foundation,Inc.,59TemplePlace,Suite330,Boston,MA02111-1307USA**IncaseyourcopyofSunriseSpelldoesnotincludeacopyofthelicense,youmayfinditonlineat**/usingSystem;usingSystem.Text;namespaceK50018.Basic{///summary///提供用于设置转换选项的枚举值。////summary///value///codeFirstLetterOnly/code///只转换拼音首字母,默认转换全部////value///value///codeTranslateUnknowWordToInterrogation/code///转换未知汉字为问号,默认不转换////value///value///codeEnableUnicodeLetter/code///保留非字母、非数字字符,默认不保留////value[System.FlagsAttribute]publicenumSpellOptions{FirstLetterOnly=1,//只转换拼音首字母,默认转换全部TranslateUnknowWordToInterrogation=11,//转换未知汉字为问号,默认不转换EnableUnicodeLetter=12,//保留非字母、非数字字符,默认不保留FirstLetterUpper=14,//首字母大写,默认小写}///summary///汉字转拼音算法////summarypublicstaticclassChinese{#region字段和属性//拼音代码表readonlystaticstring[]_spellMusicCode=newstring[]{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,fu,fou,ga,gai,gan,gang,gao,ge,ji,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,jia,jian,jiang,qiao,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,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,nuan,nue,yao,nuo,o,ou,pa,pai,pan,pang,pao,pei,pen,peng,pi,pian,piao,pie,pin,ping,po,pou,pu,qi,qia,qian,qiang,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,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,,ei,m,n,dia,cen,nou,jv,qv,xv,lv,nv};//拼音索引表readonlystaticint[,]_spellCodeIndex=newint[,]{{354,279,331,0,190,39,284,67,249,167,353,19,133,92,129,152,31,385,105,131,84,348,348,329,133,0,376,116,283,349,344,87,133,0,0,0,284,202,0,0,0,0,0,0,342,345,0,276,199,243,0,0,52,0,375,102,88,176,170,348,136,180,375,0,354,294,299,94,344,368,344,55,347,333,131,347,353,369,166,74,325,92,0,329,6,19,0,306,0,332,372,114,107,20,33,370,279,258,79,191,243,328,220,83,43,324,62,376,229,354,64,73,329,348,336,92,2,349,232,282,84,305,389,357,134,332,343,336,363,332,217,208,335,340,377,389,13,232,348,294,348,374,107,181,378,21,250,14,371,47,346,369,14,332,250,284,10,121,110,333,91,78,194,19,113,123,102,251,47,337,282,320,106,157,348,101,349,189,340,3,175,77,178,29,37,343,377,263,125,294,56},{302,214,130,132,313,373,393,39,404,134,286,313,282,320,20,201,334,318,354,330,340,101,148,329,348,84,167,122,350,332,270,229,330,190,331,339,62,134,375,157,294,123,334,125,16,309,81,344,11,354,336,116,374,375,19,133,220,389,167,323,169,43,387,0,91,310,286,187,304,383,337,237,241,88,167,299,245,80,375,387,178,295,171,122,68,386,12,329,134,200,23,125,347,276,245,350,36,243,264,376,45,325,354,19,309,345,83,305,328,75,34,283,140,62,29,11,367,120,220,369,388,345,353,340,367,47,84,84,375,190,92,348,335,343,294,71,368,373,315,11,360,245,325,296,375,297,331,355,261,217,357,126,180,63,305,109,129,330,278,243,252,35,40,270,11,334,352,220,304,301,346,78,19,333,359,97,270,162,352,362,387,231,295,381,354,368,389,279,43,131,107},{370,247,349,62,335,174,11,234,130,166,175,182,243,332,304,350,68,392,278,127,132,318,392,240,160,32,101,241,308,381,325,92,20,121,45,312,278,220,82,332,354,75,170,20,97,332,332,193,347,130,242,127,83,377,2,269,348,137,216,304,348,58,150,0,125,40,128,276,359,24,18,3,303,59,30,158,348,130,243,188,329,214,248,208,32,169,404,152,10,354,16,360,375,294,353,109,247,246,164,308,325,173,4