1
//
汉字转拼音缩写(声母)
2 namespace Skyiv
3 {
4 using System;
5 using System.Text;
6 using System.Collections.Generic;
7
8 class ChinesePY
9 { // 二级字库
10 static readonly string a = " 吖锕嗄锿捱嗳霭砹嗌嫒暧瑷桉庵谙鹌埯铵揞犴黯坳嗷廒獒遨聱螯鳌鏖媪岙骜鏊A " ;
11 static readonly string b = " 岜粑茇菝魃鲅灞掰捭呗瘢癍阪坂钣舨浜蒡勹孢煲龅鸨葆褓趵陂鹎邶悖碚蓓褙鞴鐾贲锛畚坌嘣甏荸匕吡妣秕俾舭畀哔荜狴铋婢庳萆弼愎筚滗裨跸箅嬖篦薜濞髀璧襞砭笾煸蝙鳊窆匾碥褊弁忭汴苄缏飑髟骠瘭镖飙飚镳婊裱鳔蹩傧缤槟镔豳殡膑髌鬓邴禀摒饽啵孛亳钹鹁踣礴跛簸擘檗逋钸晡醭卟钚瓿玢宀疒8B " ;
12 static readonly string c = " 嚓礤骖黪粲璨伧嘈漕艚螬艹恻岑涔噌杈馇锸猹槎檫衩镲汊姹钗侪虿瘥觇婵孱禅廛潺镡蟾躔谄蒇冁忏羼伥娼菖阊鲳苌徜嫦昶惝氅怅鬯怊焯晁耖砗屮坼抻琛嗔宸谌碜龀榇谶柽蛏铛瞠丞枨埕铖裎塍酲哧蚩鸱眵笞嗤媸螭魑茌墀踟篪豉褫彳叱饬敕啻傺瘛忡茺舂憧艟铳瘳俦帱惆雠樗刍蜍蹰杵楮褚亍怵绌憷黜搋啜嘬踹巛氚舡遄舛钏怆陲棰槌蝽莼鹑踔辍龊呲祠茈鹚糍苁枞骢璁淙琮楱腠辏徂殂猝蔟蹙蹴汆C " ;
13 static readonly string d = " 哒耷嗒褡妲怛笪靼鞑岱甙绐迨玳埭黛眈聃殚瘅箪儋疸啖萏澹裆谠凼宕砀菪叨忉氘纛锝噔簦戥嶝磴镫羝嘀镝籴荻觌氐诋邸坻柢砥骶娣谛棣睇碲嗲巅癫踮阽坫玷钿癜簟貂鲷铞垤瓞堞揲耋牒蹀鲽仃玎疔耵酊啶腚碇铥咚岽氡鸫垌峒胨胴硐蔸篼蚪窦嘟渎椟牍黩髑笃芏蠹椴煅簖怼碓憝镦礅盹趸沌炖砘咄裰铎踱哚缍沲卩亻赕铫町铤夂丶D " ;
14 static readonly string e = " 屙莪锇婀呃苊轭垩谔阏愕萼腭锷鹗颚噩鳄蒽摁鸸鲕迩珥铒佴嗯唔诶2E " ;
15 static readonly string f = " 垡砝幡蕃燔蹯蘩畈梵邡枋钫鲂舫妃绯扉蜚霏鲱淝腓悱斐榧翡篚狒痱镄棼鼢偾鲼瀵沣砜葑酆唪俸缶呋趺麸稃跗凫孚芙芾怫绂绋苻祓罘茯郛砩莩蚨匐桴艴菔蜉幞蝠黻拊滏黼驸鲋赙蝮鳆馥攵犭F " ;
16 static readonly string g = " 旮伽钆尜尕尬陔垓赅丐戤坩泔苷疳酐尴澉橄擀旰矸绀淦罡筻戆槔睾杲缟槁藁诰郜锆圪纥袼鬲嗝塥搿膈镉骼哿舸虼硌哏亘艮茛赓哽绠鲠肱蚣觥珙佝缑篝鞲岣枸笱诟媾彀遘觏轱鸪菰蛄觚酤毂鹘汩诂牯罟钴嘏臌瞽崮梏牿痼锢鲴胍鸹呱卦诖倌鳏掼涫盥鹳咣桄胱犷妫皈鲑宄庋匦晷簋刿炅鳜衮绲磙鲧呙埚崞聒蝈帼掴虢馘猓椁蜾桧莞呷G " ;
17 static readonly string h = " 鹄铪嗨胲醢顸蚶鼾邗晗焓菡颔撖瀚绗颃沆蒿嚆薅蚝嗥濠昊皓颢灏诃嗬劾曷盍颌阖翮壑桁珩蘅訇薨闳泓荭蕻黉讧瘊篌糇骺後逅堠鲎虍烀轷唿惚滹囫斛猢煳鹕槲醐觳浒琥冱岵怙戽祜笏扈瓠鹱骅铧桦踝獾洹萑锾寰缳鬟奂浣逭漶鲩擐肓隍徨湟遑潢璜篁癀蟥鳇诙咴虺晖珲麾隳洄茴哕浍荟恚彗喙缋蕙蟪阍馄诨溷耠锪劐攉钬夥镬嚯藿蠖砉圜H " ;
18 static readonly string i = " I " ;
19 static readonly string j = " 丌叽乩玑芨矶咭剞唧屐笄嵇犄赍跻畿齑墼羁岌亟佶笈戢殛楫蒺瘠蕺虮掎戟嵴麂芰哜洎觊偈暨跽霁鲚稷鲫髻骥迦浃痂笳袈葭跏镓岬郏恝戛铗蛱胛瘕戋菅湔犍搛缣蒹鲣鹣鞯囝枧笕趼睑裥锏谫戬翦謇蹇牮谏楗毽腱僭踺茳豇缰礓耩洚绛犟糨艽姣茭蛟跤僬鲛鹪佼挢皎敫徼噍醮疖嗟孑讦诘拮桀婕颉碣鲒羯蚧骱钅矜衿卺堇廑馑槿瑾妗荩赆缙觐噤泾旌菁腈阱刭肼儆憬弪迳胫婧獍扃迥鸠赳阄啾鬏柩桕噘孓珏崛桷觖厥劂谲獗蕨橛镢蹶矍爝皲筠麇捃纟廴鄄莒9J " ;
20 static readonly string k = " 蚵咔佧胩锎剀垲恺铠蒈锴忾龛戡侃莰阚瞰伉闶钪尻栲铐犒珂轲疴钶颏稞窠瞌蝌髁岢恪氪骒缂嗑溘锞裉铿倥崆箜芤叩筘蔻刳堀骷绔喾侉蒯郐哙狯脍髋诓哐诳夼邝圹纩贶悝逵馗喹揆暌睽蝰夔跬匮喟愦蒉篑聩琨锟髡醌鲲悃阃栝蛞K " ;
21 static readonly string l = " 冫靓邋旯砬剌瘌崃徕涞铼赉睐濑癞籁岚褴斓镧榄漤罱啷莨稂锒螂阆蒗唠崂痨铹醪栳铑耢仂叻泐鳓嫘缧檑羸耒诔酹嘞塄愣骊喱鹂缡蓠蜊嫠鲡罹藜黧蠡俚娌逦锂澧醴鳢呖坜苈戾枥疠俪栎疬轹郦猁砺莅唳笠粝蛎詈跞雳溧篥奁裢鲢濂臁蠊琏裣蔹娈殓楝潋椋墚踉魉嘹寮獠缭鹩钌蓼咧冽洌埒捩趔躐鬣啉粼嶙遴辚瞵麟廪懔檩蔺膦躏囹泠苓柃瓴棂绫翎聆蛉鲮酃呤熘浏旒遛骝镏鎏绺锍鹨泷茏栊珑胧砻癃泸06L " ;
22 static readonly string m = " 膂褛栾鸾脔銮锊囵捋猡脶椤镙倮瘰蠃泺荦珞摞漯雒呒嬷蟆犸杩唛霾荬劢颟鞔鳗螨墁幔缦熳镘邙硭漭蟒牦旄蛑髦蝥蟊峁泖茆昴耄袤瑁瞀懋莓嵋湄猸楣镅鹛浼袂魅扪钔焖懑虻甍瞢朦礞艨勐艋蜢懵蠓咪祢猕縻麋蘼芈弭敉脒糸汨宓谧嘧沔黾眄湎腼喵鹋杪眇淼缈邈咩篾蠛岷玟苠珉缗闵泯愍鳘茗冥溟暝瞑酩缪谟嫫馍麽殁茉秣蓦貊瘼镆貘耱哞侔眸鍪毪仫沐坶苜钼渑M " ;
23 static readonly string n = " 拗廾乜镎肭衲捺艿柰萘鼐囡喃楠赧腩蝻囔馕曩攮孬呶硇铙猱蛲垴瑙讷坭怩铌猊鲵伲旎昵睨鲇鲶黏辇廿埝茑袅嬲脲陧臬嗫颞蹑蘖咛聍佞甯妞忸狃侬哝耨孥驽弩胬钕恧衄傩喏搦锘恁N " ;
24 static readonly string o = " 噢讴瓯耦怄O " ;
25 static readonly string p = " 钯拚彷冖葩杷筢俳哌蒎爿蹒蟠泮袢襻滂逄螃脬庖狍匏疱醅锫帔旆辔霈湓怦嘭堋蟛丕纰邳铍噼芘枇蚍郫陴埤罴蜱貔鼙庀仳圮擗癖淠媲睥甓犏翩骈胼蹁谝剽缥螵殍瞟嘌嫖氕丿苤姘嫔颦榀牝娉俜枰鲆钋鄱皤叵钷笸珀掊裒攴噗匍璞濮镤溥氆镨蹼P " ;
26 static readonly string q = " 匚袷湫峤趄瞿桤萋嘁槭蹊亓圻岐芪耆颀淇萁骐琦琪祺蛴綦蜞蕲鳍麒屺芑杞绮綮汔荠葺碛憩葜髂阡芊佥岍悭愆骞搴褰钤虔掮箝肷慊缱芡茜倩椠戕戗跄蜣锖锵镪嫱樯羟襁炝硗跷劁缲荞谯憔鞒樵愀诮妾挈惬箧锲衾芩嗪溱噙檎螓锓吣揿圊蜻鲭檠黥苘謦箐磬罄跫銎邛穹茕筇蛩蚯楸鳅犰虬俅逑赇巯遒裘蝤鼽糗岖诎祛蛐麴黢劬朐鸲蕖磲璩蘧氍癯衢蠼阒觑悛诠荃辁铨筌蜷鬈畎绻悫阕阙逡郄7Q " ;
27 static readonly string r = " 蚺髯苒禳穰荛桡娆荏稔仞轫饪衽肜狨嵘榕蝾糅蹂鞣铷嚅濡薷襦颥洳溽缛蓐朊蕤芮枘蚋睿偌箬R " ;
28 static readonly string s = " 灬杓丨凵葚仨卅飒脎噻毵糁馓搡磉颡缫臊鳋埽瘙啬铯穑铩痧裟鲨唼歃霎彡芟姗钐埏舢跚潸膻讪疝骟鄯嬗蟮鳝殇觞熵垧绱筲艄蛸劭潲猞畲佘厍滠麝诜哂矧谂渖胂椹蜃笙眚晟嵊蓍酾鲺饣炻埘莳鲥豕礻贳舐轼铈弑谥筮螫艏狩绶殳纾姝倏菽摅毹秫塾沭腧澍唰蟀闩涮孀氵妁铄嗍搠蒴槊厶咝鸶缌蛳厮锶澌汜兕姒祀泗驷俟笥耜忪凇崧淞菘嵩悚竦嗖溲馊飕锼螋叟嗾瞍薮稣夙涑谡嗉愫蔌觫簌狻荽眭睢濉谇莘34S " ;
29 static readonly string t = " 沓呔焘钭冂苕扌趿铊溻鳎闼遢榻骀邰炱跆鲐薹肽钛昙郯覃锬忐钽铴羰镗饧溏瑭樘螗螳醣帑傥耥韬饕洮啕鼗忑忒铽慝滕绨缇鹈醍倜悌逖裼畋阗忝殄掭佻祧笤龆蜩髫鲦窕粜萜餮莛婷葶蜓霆梃嗵仝佟茼砼僮潼恸骰荼酴钍堍菟抟疃彖煺暾饨豚氽乇佗坨沱柁砣跎酡橐鼍庹柝箨T " ;
30 static readonly string u = " U " ;
31 static readonly string v = " V " ;
32 static readonly string w = " 亠娲佤腽崴剜蜿纨芄绾脘菀琬畹罔惘辋魍偎逶隈葳煨薇囗帏沩闱涠帷嵬炜玮洧娓诿隗猥痿艉韪鲔軎猬阌雯刎汶璺蓊蕹倭莴喔肟幄渥硪龌圬邬浯蜈鼯仵妩庑忤怃迕牾鹉兀阢杌芴焐婺痦骛寤鹜鋈5W " ;
33 static readonly string x = " 郇彐噱荨圩兮穸郗唏奚浠欷淅菥粞翕舾皙僖蜥嬉樨歙熹羲螅蟋醯曦鼷觋隰玺徙葸屣蓰禧饩阋舄禊狎柙硖遐瑕黠罅氙祆籼莶跹酰暹娴痫鹇冼猃蚬筅跣藓燹岘苋霰芗缃葙骧庠饷飨鲞蟓枭哓枵骁绡逍潇箫魈崤筱偕勰撷缬绁亵渫榍榭廨獬薤邂燮瀣躞昕歆馨鑫囟陉硎擤荇悻芎咻庥鸺貅馐髹岫溴盱胥顼诩栩糈醑洫勖溆煦蓿谖揎萱暄煊儇痃漩璇泫炫铉渲楦碹镟泶踅鳕谑埙窨獯薰曛醺峋恂洵浔荀鲟徇巽X " ;
34 static readonly string y = " 肀剡桠伢岈琊睚痖迓垭娅砑氩揠恹胭崦菸湮腌鄢嫣讠闫妍芫筵檐兖俨偃厣郾琰罨魇鼹晏焱滟酽谳餍赝泱鞅炀徉烊蛘怏恙幺夭吆爻肴轺珧徭繇鳐杳窈崾鹞曜揶铘邺晔烨谒靥衤咿猗欹漪噫黟圯诒怡迤饴咦荑贻眙酏痍嶷钇苡舣旖弋刈仡佚呓佾峄怿驿奕弈羿轶悒挹埸翊缢瘗蜴熠镒劓殪薏翳癔镱懿洇氤铟喑堙垠狺鄞夤龈霪吲蚓瘾茚胤莺瑛嘤撄罂璎鹦膺茔荥萦楹滢蓥潆嬴瀛郢颍瘿媵唷邕墉慵壅镛鳙狳谀馀萸雩嵛揄腴瑜觎窬蝓伛俣圄圉庾瘐窳龉聿妪饫昱钰谕阈鹆煜蓣毓蜮燠鹬鬻鸢眢箢沅爰鼋塬橼螈垸媛掾瑗刖钺樾龠瀹纭芸昀氲狁殒郓恽愠韫熨攸禺1Y " ;
35 static readonly string z = " 辶酢喋阝咂拶甾崽糌簪昝趱錾瓒臧驵奘唣迮啧帻笮舴箦赜仄昃谮缯罾锃甑吒哳揸楂齄砟咤痄蚱砦瘵旃谵搌鄣嫜獐璋蟑仉嶂幛钊啁诏笊棹蜇辄谪摺磔赭褶柘鹧浈桢祯蓁榛箴胗轸畛缜稹圳鸩朕赈峥钲铮筝徵诤卮栀祗胝埴絷跖摭踯芷祉咫枳轵黹酯忮豸帙郅栉陟桎贽轾鸷彘痣蛭骘雉膣觯踬舯锺螽冢踵妯碡纣绉胄荮酎籀侏邾洙茱铢槠潴橥竺舳瘃躅渚麈伫苎杼炷疰箸翥颛啭馔丬隹骓惴缒肫窀倬涿斫菹镞俎躜缵攥蕞樽鳟撙阼怍祚胙唑秭梓Z " ;
36 static string [] word2 = new string []{ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z };
37
38 // 要转换的汉字字符串 返回:拼音缩写
39 public static string GetPYString( string str)
40 {
41 string pyStr = "" ;
42 foreach ( char c in str)
43 {
44 if (( int )c > 32 && ( int )c <= 126 ) pyStr += Char.ToLower(c).ToString(); // 字母和符号原样保留
45 else if (( int )c > 126 ) pyStr += GetPYChar(c.ToString()); // 累加拼音声母
46 }
47 return pyStr;
48 }
49
50 // 要转换的单个汉字 返回:拼音声母
51 public static string GetPYChar( string c)
52 {
53 byte [] array = new byte [ 2 ];
54 array = Encoding.GetEncoding( " GB18030 " ).GetBytes(c);
55 int i = ( int )array[ 0 ] * 256 + ( int )array[ 1 ];
56 if (i < 0xB0A1 ) return GetPYChar2(c);
57 if (i < 0xB0C5 ) return " a " ;
58 if (i < 0xB2C1 ) return " b " ;
59 if (i < 0xB4EE ) return " c " ;
60 if (i < 0xB6EA ) return " d " ;
61 if (i < 0xB7A2 ) return " e " ;
62 if (i < 0xB8C1 ) return " f " ;
63 if (i < 0xB9FE ) return " g " ;
64 if (i < 0xBBF7 ) return " h " ;
65 if (i < 0xBFA6 ) return " j " ;
66 if (i < 0xC0AC ) return " k " ;
67 if (i < 0xC2E8 ) return " l " ;
68 if (i < 0xC4C3 ) return " m " ;
69 if (i < 0xC5B6 ) return " n " ;
70 if (i < 0xC5BE ) return " o " ;
71 if (i < 0xC6DA ) return " p " ;
72 if (i < 0xC8BB ) return " q " ;
73 if (i < 0xC8F6 ) return " r " ;
74 if (i < 0xCBFA ) return " s " ;
75 if (i < 0xCDDA ) return " t " ;
76 if (i < 0xCEF4 ) return " w " ;
77 if (i < 0xD1B9 ) return " x " ;
78 if (i < 0xD4D1 ) return " y " ;
79 if (i < 0xD7FA ) return " z " ;
80 return GetPYChar2(c);
81 }
82
83 // 二级字库的声母
84 static string GetPYChar2( string c)
85 {
86 for ( int i = 0 ; i < 26 ; i ++ )
87 { // a
88 if (word2[i].IndexOf(c) >= 0 ) return (( char )(i + 97 )).ToString();
89 }
90 return " * " ;
91 }
92
93 static void Main()
94 {
95 Console.WriteLine(GetPYString( " 沱牌曲酒 南方小康指数ETF " ));
96 }
97 }
98 }
99
2 namespace Skyiv
3 {
4 using System;
5 using System.Text;
6 using System.Collections.Generic;
7
8 class ChinesePY
9 { // 二级字库
10 static readonly string a = " 吖锕嗄锿捱嗳霭砹嗌嫒暧瑷桉庵谙鹌埯铵揞犴黯坳嗷廒獒遨聱螯鳌鏖媪岙骜鏊A " ;
11 static readonly string b = " 岜粑茇菝魃鲅灞掰捭呗瘢癍阪坂钣舨浜蒡勹孢煲龅鸨葆褓趵陂鹎邶悖碚蓓褙鞴鐾贲锛畚坌嘣甏荸匕吡妣秕俾舭畀哔荜狴铋婢庳萆弼愎筚滗裨跸箅嬖篦薜濞髀璧襞砭笾煸蝙鳊窆匾碥褊弁忭汴苄缏飑髟骠瘭镖飙飚镳婊裱鳔蹩傧缤槟镔豳殡膑髌鬓邴禀摒饽啵孛亳钹鹁踣礴跛簸擘檗逋钸晡醭卟钚瓿玢宀疒8B " ;
12 static readonly string c = " 嚓礤骖黪粲璨伧嘈漕艚螬艹恻岑涔噌杈馇锸猹槎檫衩镲汊姹钗侪虿瘥觇婵孱禅廛潺镡蟾躔谄蒇冁忏羼伥娼菖阊鲳苌徜嫦昶惝氅怅鬯怊焯晁耖砗屮坼抻琛嗔宸谌碜龀榇谶柽蛏铛瞠丞枨埕铖裎塍酲哧蚩鸱眵笞嗤媸螭魑茌墀踟篪豉褫彳叱饬敕啻傺瘛忡茺舂憧艟铳瘳俦帱惆雠樗刍蜍蹰杵楮褚亍怵绌憷黜搋啜嘬踹巛氚舡遄舛钏怆陲棰槌蝽莼鹑踔辍龊呲祠茈鹚糍苁枞骢璁淙琮楱腠辏徂殂猝蔟蹙蹴汆C " ;
13 static readonly string d = " 哒耷嗒褡妲怛笪靼鞑岱甙绐迨玳埭黛眈聃殚瘅箪儋疸啖萏澹裆谠凼宕砀菪叨忉氘纛锝噔簦戥嶝磴镫羝嘀镝籴荻觌氐诋邸坻柢砥骶娣谛棣睇碲嗲巅癫踮阽坫玷钿癜簟貂鲷铞垤瓞堞揲耋牒蹀鲽仃玎疔耵酊啶腚碇铥咚岽氡鸫垌峒胨胴硐蔸篼蚪窦嘟渎椟牍黩髑笃芏蠹椴煅簖怼碓憝镦礅盹趸沌炖砘咄裰铎踱哚缍沲卩亻赕铫町铤夂丶D " ;
14 static readonly string e = " 屙莪锇婀呃苊轭垩谔阏愕萼腭锷鹗颚噩鳄蒽摁鸸鲕迩珥铒佴嗯唔诶2E " ;
15 static readonly string f = " 垡砝幡蕃燔蹯蘩畈梵邡枋钫鲂舫妃绯扉蜚霏鲱淝腓悱斐榧翡篚狒痱镄棼鼢偾鲼瀵沣砜葑酆唪俸缶呋趺麸稃跗凫孚芙芾怫绂绋苻祓罘茯郛砩莩蚨匐桴艴菔蜉幞蝠黻拊滏黼驸鲋赙蝮鳆馥攵犭F " ;
16 static readonly string g = " 旮伽钆尜尕尬陔垓赅丐戤坩泔苷疳酐尴澉橄擀旰矸绀淦罡筻戆槔睾杲缟槁藁诰郜锆圪纥袼鬲嗝塥搿膈镉骼哿舸虼硌哏亘艮茛赓哽绠鲠肱蚣觥珙佝缑篝鞲岣枸笱诟媾彀遘觏轱鸪菰蛄觚酤毂鹘汩诂牯罟钴嘏臌瞽崮梏牿痼锢鲴胍鸹呱卦诖倌鳏掼涫盥鹳咣桄胱犷妫皈鲑宄庋匦晷簋刿炅鳜衮绲磙鲧呙埚崞聒蝈帼掴虢馘猓椁蜾桧莞呷G " ;
17 static readonly string h = " 鹄铪嗨胲醢顸蚶鼾邗晗焓菡颔撖瀚绗颃沆蒿嚆薅蚝嗥濠昊皓颢灏诃嗬劾曷盍颌阖翮壑桁珩蘅訇薨闳泓荭蕻黉讧瘊篌糇骺後逅堠鲎虍烀轷唿惚滹囫斛猢煳鹕槲醐觳浒琥冱岵怙戽祜笏扈瓠鹱骅铧桦踝獾洹萑锾寰缳鬟奂浣逭漶鲩擐肓隍徨湟遑潢璜篁癀蟥鳇诙咴虺晖珲麾隳洄茴哕浍荟恚彗喙缋蕙蟪阍馄诨溷耠锪劐攉钬夥镬嚯藿蠖砉圜H " ;
18 static readonly string i = " I " ;
19 static readonly string j = " 丌叽乩玑芨矶咭剞唧屐笄嵇犄赍跻畿齑墼羁岌亟佶笈戢殛楫蒺瘠蕺虮掎戟嵴麂芰哜洎觊偈暨跽霁鲚稷鲫髻骥迦浃痂笳袈葭跏镓岬郏恝戛铗蛱胛瘕戋菅湔犍搛缣蒹鲣鹣鞯囝枧笕趼睑裥锏谫戬翦謇蹇牮谏楗毽腱僭踺茳豇缰礓耩洚绛犟糨艽姣茭蛟跤僬鲛鹪佼挢皎敫徼噍醮疖嗟孑讦诘拮桀婕颉碣鲒羯蚧骱钅矜衿卺堇廑馑槿瑾妗荩赆缙觐噤泾旌菁腈阱刭肼儆憬弪迳胫婧獍扃迥鸠赳阄啾鬏柩桕噘孓珏崛桷觖厥劂谲獗蕨橛镢蹶矍爝皲筠麇捃纟廴鄄莒9J " ;
20 static readonly string k = " 蚵咔佧胩锎剀垲恺铠蒈锴忾龛戡侃莰阚瞰伉闶钪尻栲铐犒珂轲疴钶颏稞窠瞌蝌髁岢恪氪骒缂嗑溘锞裉铿倥崆箜芤叩筘蔻刳堀骷绔喾侉蒯郐哙狯脍髋诓哐诳夼邝圹纩贶悝逵馗喹揆暌睽蝰夔跬匮喟愦蒉篑聩琨锟髡醌鲲悃阃栝蛞K " ;
21 static readonly string l = " 冫靓邋旯砬剌瘌崃徕涞铼赉睐濑癞籁岚褴斓镧榄漤罱啷莨稂锒螂阆蒗唠崂痨铹醪栳铑耢仂叻泐鳓嫘缧檑羸耒诔酹嘞塄愣骊喱鹂缡蓠蜊嫠鲡罹藜黧蠡俚娌逦锂澧醴鳢呖坜苈戾枥疠俪栎疬轹郦猁砺莅唳笠粝蛎詈跞雳溧篥奁裢鲢濂臁蠊琏裣蔹娈殓楝潋椋墚踉魉嘹寮獠缭鹩钌蓼咧冽洌埒捩趔躐鬣啉粼嶙遴辚瞵麟廪懔檩蔺膦躏囹泠苓柃瓴棂绫翎聆蛉鲮酃呤熘浏旒遛骝镏鎏绺锍鹨泷茏栊珑胧砻癃泸06L " ;
22 static readonly string m = " 膂褛栾鸾脔銮锊囵捋猡脶椤镙倮瘰蠃泺荦珞摞漯雒呒嬷蟆犸杩唛霾荬劢颟鞔鳗螨墁幔缦熳镘邙硭漭蟒牦旄蛑髦蝥蟊峁泖茆昴耄袤瑁瞀懋莓嵋湄猸楣镅鹛浼袂魅扪钔焖懑虻甍瞢朦礞艨勐艋蜢懵蠓咪祢猕縻麋蘼芈弭敉脒糸汨宓谧嘧沔黾眄湎腼喵鹋杪眇淼缈邈咩篾蠛岷玟苠珉缗闵泯愍鳘茗冥溟暝瞑酩缪谟嫫馍麽殁茉秣蓦貊瘼镆貘耱哞侔眸鍪毪仫沐坶苜钼渑M " ;
23 static readonly string n = " 拗廾乜镎肭衲捺艿柰萘鼐囡喃楠赧腩蝻囔馕曩攮孬呶硇铙猱蛲垴瑙讷坭怩铌猊鲵伲旎昵睨鲇鲶黏辇廿埝茑袅嬲脲陧臬嗫颞蹑蘖咛聍佞甯妞忸狃侬哝耨孥驽弩胬钕恧衄傩喏搦锘恁N " ;
24 static readonly string o = " 噢讴瓯耦怄O " ;
25 static readonly string p = " 钯拚彷冖葩杷筢俳哌蒎爿蹒蟠泮袢襻滂逄螃脬庖狍匏疱醅锫帔旆辔霈湓怦嘭堋蟛丕纰邳铍噼芘枇蚍郫陴埤罴蜱貔鼙庀仳圮擗癖淠媲睥甓犏翩骈胼蹁谝剽缥螵殍瞟嘌嫖氕丿苤姘嫔颦榀牝娉俜枰鲆钋鄱皤叵钷笸珀掊裒攴噗匍璞濮镤溥氆镨蹼P " ;
26 static readonly string q = " 匚袷湫峤趄瞿桤萋嘁槭蹊亓圻岐芪耆颀淇萁骐琦琪祺蛴綦蜞蕲鳍麒屺芑杞绮綮汔荠葺碛憩葜髂阡芊佥岍悭愆骞搴褰钤虔掮箝肷慊缱芡茜倩椠戕戗跄蜣锖锵镪嫱樯羟襁炝硗跷劁缲荞谯憔鞒樵愀诮妾挈惬箧锲衾芩嗪溱噙檎螓锓吣揿圊蜻鲭檠黥苘謦箐磬罄跫銎邛穹茕筇蛩蚯楸鳅犰虬俅逑赇巯遒裘蝤鼽糗岖诎祛蛐麴黢劬朐鸲蕖磲璩蘧氍癯衢蠼阒觑悛诠荃辁铨筌蜷鬈畎绻悫阕阙逡郄7Q " ;
27 static readonly string r = " 蚺髯苒禳穰荛桡娆荏稔仞轫饪衽肜狨嵘榕蝾糅蹂鞣铷嚅濡薷襦颥洳溽缛蓐朊蕤芮枘蚋睿偌箬R " ;
28 static readonly string s = " 灬杓丨凵葚仨卅飒脎噻毵糁馓搡磉颡缫臊鳋埽瘙啬铯穑铩痧裟鲨唼歃霎彡芟姗钐埏舢跚潸膻讪疝骟鄯嬗蟮鳝殇觞熵垧绱筲艄蛸劭潲猞畲佘厍滠麝诜哂矧谂渖胂椹蜃笙眚晟嵊蓍酾鲺饣炻埘莳鲥豕礻贳舐轼铈弑谥筮螫艏狩绶殳纾姝倏菽摅毹秫塾沭腧澍唰蟀闩涮孀氵妁铄嗍搠蒴槊厶咝鸶缌蛳厮锶澌汜兕姒祀泗驷俟笥耜忪凇崧淞菘嵩悚竦嗖溲馊飕锼螋叟嗾瞍薮稣夙涑谡嗉愫蔌觫簌狻荽眭睢濉谇莘34S " ;
29 static readonly string t = " 沓呔焘钭冂苕扌趿铊溻鳎闼遢榻骀邰炱跆鲐薹肽钛昙郯覃锬忐钽铴羰镗饧溏瑭樘螗螳醣帑傥耥韬饕洮啕鼗忑忒铽慝滕绨缇鹈醍倜悌逖裼畋阗忝殄掭佻祧笤龆蜩髫鲦窕粜萜餮莛婷葶蜓霆梃嗵仝佟茼砼僮潼恸骰荼酴钍堍菟抟疃彖煺暾饨豚氽乇佗坨沱柁砣跎酡橐鼍庹柝箨T " ;
30 static readonly string u = " U " ;
31 static readonly string v = " V " ;
32 static readonly string w = " 亠娲佤腽崴剜蜿纨芄绾脘菀琬畹罔惘辋魍偎逶隈葳煨薇囗帏沩闱涠帷嵬炜玮洧娓诿隗猥痿艉韪鲔軎猬阌雯刎汶璺蓊蕹倭莴喔肟幄渥硪龌圬邬浯蜈鼯仵妩庑忤怃迕牾鹉兀阢杌芴焐婺痦骛寤鹜鋈5W " ;
33 static readonly string x = " 郇彐噱荨圩兮穸郗唏奚浠欷淅菥粞翕舾皙僖蜥嬉樨歙熹羲螅蟋醯曦鼷觋隰玺徙葸屣蓰禧饩阋舄禊狎柙硖遐瑕黠罅氙祆籼莶跹酰暹娴痫鹇冼猃蚬筅跣藓燹岘苋霰芗缃葙骧庠饷飨鲞蟓枭哓枵骁绡逍潇箫魈崤筱偕勰撷缬绁亵渫榍榭廨獬薤邂燮瀣躞昕歆馨鑫囟陉硎擤荇悻芎咻庥鸺貅馐髹岫溴盱胥顼诩栩糈醑洫勖溆煦蓿谖揎萱暄煊儇痃漩璇泫炫铉渲楦碹镟泶踅鳕谑埙窨獯薰曛醺峋恂洵浔荀鲟徇巽X " ;
34 static readonly string y = " 肀剡桠伢岈琊睚痖迓垭娅砑氩揠恹胭崦菸湮腌鄢嫣讠闫妍芫筵檐兖俨偃厣郾琰罨魇鼹晏焱滟酽谳餍赝泱鞅炀徉烊蛘怏恙幺夭吆爻肴轺珧徭繇鳐杳窈崾鹞曜揶铘邺晔烨谒靥衤咿猗欹漪噫黟圯诒怡迤饴咦荑贻眙酏痍嶷钇苡舣旖弋刈仡佚呓佾峄怿驿奕弈羿轶悒挹埸翊缢瘗蜴熠镒劓殪薏翳癔镱懿洇氤铟喑堙垠狺鄞夤龈霪吲蚓瘾茚胤莺瑛嘤撄罂璎鹦膺茔荥萦楹滢蓥潆嬴瀛郢颍瘿媵唷邕墉慵壅镛鳙狳谀馀萸雩嵛揄腴瑜觎窬蝓伛俣圄圉庾瘐窳龉聿妪饫昱钰谕阈鹆煜蓣毓蜮燠鹬鬻鸢眢箢沅爰鼋塬橼螈垸媛掾瑗刖钺樾龠瀹纭芸昀氲狁殒郓恽愠韫熨攸禺1Y " ;
35 static readonly string z = " 辶酢喋阝咂拶甾崽糌簪昝趱錾瓒臧驵奘唣迮啧帻笮舴箦赜仄昃谮缯罾锃甑吒哳揸楂齄砟咤痄蚱砦瘵旃谵搌鄣嫜獐璋蟑仉嶂幛钊啁诏笊棹蜇辄谪摺磔赭褶柘鹧浈桢祯蓁榛箴胗轸畛缜稹圳鸩朕赈峥钲铮筝徵诤卮栀祗胝埴絷跖摭踯芷祉咫枳轵黹酯忮豸帙郅栉陟桎贽轾鸷彘痣蛭骘雉膣觯踬舯锺螽冢踵妯碡纣绉胄荮酎籀侏邾洙茱铢槠潴橥竺舳瘃躅渚麈伫苎杼炷疰箸翥颛啭馔丬隹骓惴缒肫窀倬涿斫菹镞俎躜缵攥蕞樽鳟撙阼怍祚胙唑秭梓Z " ;
36 static string [] word2 = new string []{ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z };
37
38 // 要转换的汉字字符串 返回:拼音缩写
39 public static string GetPYString( string str)
40 {
41 string pyStr = "" ;
42 foreach ( char c in str)
43 {
44 if (( int )c > 32 && ( int )c <= 126 ) pyStr += Char.ToLower(c).ToString(); // 字母和符号原样保留
45 else if (( int )c > 126 ) pyStr += GetPYChar(c.ToString()); // 累加拼音声母
46 }
47 return pyStr;
48 }
49
50 // 要转换的单个汉字 返回:拼音声母
51 public static string GetPYChar( string c)
52 {
53 byte [] array = new byte [ 2 ];
54 array = Encoding.GetEncoding( " GB18030 " ).GetBytes(c);
55 int i = ( int )array[ 0 ] * 256 + ( int )array[ 1 ];
56 if (i < 0xB0A1 ) return GetPYChar2(c);
57 if (i < 0xB0C5 ) return " a " ;
58 if (i < 0xB2C1 ) return " b " ;
59 if (i < 0xB4EE ) return " c " ;
60 if (i < 0xB6EA ) return " d " ;
61 if (i < 0xB7A2 ) return " e " ;
62 if (i < 0xB8C1 ) return " f " ;
63 if (i < 0xB9FE ) return " g " ;
64 if (i < 0xBBF7 ) return " h " ;
65 if (i < 0xBFA6 ) return " j " ;
66 if (i < 0xC0AC ) return " k " ;
67 if (i < 0xC2E8 ) return " l " ;
68 if (i < 0xC4C3 ) return " m " ;
69 if (i < 0xC5B6 ) return " n " ;
70 if (i < 0xC5BE ) return " o " ;
71 if (i < 0xC6DA ) return " p " ;
72 if (i < 0xC8BB ) return " q " ;
73 if (i < 0xC8F6 ) return " r " ;
74 if (i < 0xCBFA ) return " s " ;
75 if (i < 0xCDDA ) return " t " ;
76 if (i < 0xCEF4 ) return " w " ;
77 if (i < 0xD1B9 ) return " x " ;
78 if (i < 0xD4D1 ) return " y " ;
79 if (i < 0xD7FA ) return " z " ;
80 return GetPYChar2(c);
81 }
82
83 // 二级字库的声母
84 static string GetPYChar2( string c)
85 {
86 for ( int i = 0 ; i < 26 ; i ++ )
87 { // a
88 if (word2[i].IndexOf(c) >= 0 ) return (( char )(i + 97 )).ToString();
89 }
90 return " * " ;
91 }
92
93 static void Main()
94 {
95 Console.WriteLine(GetPYString( " 沱牌曲酒 南方小康指数ETF " ));
96 }
97 }
98 }
99