首页 > 编程 > JavaScript > 正文

javascript实现根据汉字获取简拼

2019-11-20 08:53:17
字体:
来源:转载
供稿:网友

主要用于模糊查询,或者快速查找

代码如下

<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame Remove this if you use the .htaccess --> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>汉字简拼</title> <meta name="description" content=""> <meta name="author" content="Administrator"> <meta name="viewport" content="width=device-width; initial-scale=1.0"> <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references --> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> </head> <body> <center>  <input type="text" id="wordC" />  <input type="button" id="btn" value="获取简拼" />  <h1 id="wordE">  </h1> </center> </body>  <script type="text/javascript"> window.onload = function() {    document.getElementById("btn").onclick = function() {  var wordC = document.getElementById("wordC").value;  var wordE = letterArr(wordC);  document.getElementById("wordE").innerHTML = wordE.toUpperCase();  };  //获取字符串首字母  /**  * arrInitialChart数组将unicode 19968-40869 编码分为26个元素,每个元素的首字母都相同,按英文字符排序  * arrNumLetter数组为每个arrInitialChart数组的元素id所对应的英文字母  * arrPolyphone数组为377个声母不同的多音字的首字母字符串  */  var arrInitialChart = new Array();  arrInitialChart[0]="俺傲凹哀哎唉啊嗄嗌嗳嗷坳埃埯奥媪嫒安岙岸庵廒懊按挨捱揞敖昂暗暧案桉氨澳熬爱犴獒瑷癌皑盎矮砹碍翱聱肮胺艾蔼螯袄谙遨鏊鏖铵锕锿阿隘霭鞍骜鳌鹌黯";  arrInitialChart[1]="不丙亳伯伴佛佰便保俾倍傍傧八兵冰别剥办勃勹包匕北匾半卑博卜卞卟变叭吡吧呗哔哺啵嘣坂坌坝埠堡壁备夯奔妣婊婢嬖孛孢宀宝宾岜崩巴币布帛帮并庇庳弁弊弼彪彬彼必忭怖悖悲惫愎憋扁扒扮扳把报抱拌拔拜拨捌捕捭掰搏搬摆摈摒播擘敝斌斑晡暴本杯板柄柏标梆棒榜槟檗步殡比毕毖毙汴泊波泵浜渤滗滨濒濞瀑灞炳焙煲煸爆爸版狈狴玢玻班璧瓣瓿甏甭畀畚疒疤病痹瘢瘪瘭癍白百砭碑碚碥碧磅礴禀秉秕稗窆笆笔笨笾筚箅箔篦簸簿粑绊绑绷缏编缤罢背胞脖膀膊膑膘臂舨般舭舶芭苄苞苯茇荜荸菝菠萆葆蒡蓓蓖蔽薄薜蚌蝙补表被裨裱褊褒褓褙襞谤豳豹贝败贬贲趵跋跛跸踣蹦蹩辈辨辩辫边迸逋逼遍避邦邴邶部鄙醭鐾钚钡钣钵钸钹铂铋锛镑镔镖镳闭阪陂陛雹霸靶鞭鞴颁飑飙飚饱饼饽驳骠髀髌髟鬓魃鲅鲍鳊鳔鳖鸨鹁鹎鼻龅";  arrInitialChart[2]="丑丛丞串乘亍产仇从仓传伥伧侈侧侪促俦倡偿储催傺充冁册冲凑出刂刍创初刹刺匆厂厕厝厨参叉叱吃吵吹呈呲哧唇唱啐啜啻喘嗔嗤嘈嘬嘲噌嚓囱场坼垂城埕塍墀处姹娼婵媸嫦存孱宠宸察寸尘尝尺层屮岑岔崇崔嵯巛川巢差帱常床廛弛彩彳彻徂徜忏忖忡忱怅怆怊怵恻悴惆惝惨惩惭愁慈憧憷成戳才扯承抄抻抽拆持挫捶掣措掺插揣搀搋搐搓搽摧撑撤撮撺操擦敕敞斥昌春昶晁晨曹曾朝杈材村杵枞枨查柴柽棰椽椿楚楮楱榇榱槌槎槽樗橙橱檫次此殂残毳氅氚汆汊池沉沧测涔淙淬淳滁漕潮潺澄澈澶灿炊炒炽焯爨猖猜猝猹琛琮璀璁璨瓷畅畜畴疮疵痤痴瘁瘛瘥瘳皴眵睬瞅瞠矗矬砗础碜碴磁磋礤祠禅秤称程稠穿窗窜笞策筹篡篪簇粗粢粲粹糍糙纯绌绰绸缠羼翅翠耖耻聪肠脆脞腠膪臣臭舂舛舡舱船艚艟艹苁苌苍茈茌茨茬茶茺草莼菖菜萃葱蒇蔟蔡藏虫虿蚕蚩蛏蜍蝉蝽螬螭蟾蠢衩衬裁裎褚褫觇触词诚诧谄谌谗谶豉豺财赐赤趁超踌踔踟踩踹蹉蹙蹭蹰蹴蹿躇躔车辍辏辞辰迟逞遄郴酬酲醇醋采钏钗钞铖铛铲铳锄锉错锤锸镡镩镲闯阊阐陈除陲雌雏雠颤餐饬馇馋驰骋骖骢骣鬯魑鲳鸱鹑鹚鹾黜黪齿龀龊";  arrInitialChart[3]="丁东丢丶丹亻仃代佃但低侗倒傣儋兑党兜典冬冻凋凳凼刀刁到剁动单卩叠叨叮叼吊吨呆咄咚哆哒哚啖啶嗒嗲嘀嘟噔地坫坻垌垛垤垫埭堆堕堞堤堵墩夂多大夺奠妒妲娣嫡宕定对导岛岱岽峒嶝巅帝带底店度弟弹当待得德忉怛怠怼恫悼惦惮惰憝懂戥戴打抖抵担挡捣掂掇掉掸揲搭敌敦斗断旦朵杜柢栋档棣椟椴歹殆殚段殿毒氐氘氡氮沌沲洞涤淀淡渎渡滇滴澹灯炖点煅爹牍牒犊狄独玎玳玷瓞甙电甸町疔疸痘瘅瘩癜癫登的盗盯盹盾眈睇督睹瞪短砀砘砥硐碇碉碓碘碟碲磴礅祷稻窦端笃笛笪第等答箪篼簖簟簦籴纛绐缍缎缔羝耋耵耷耽聃肚胆胨胴腚舵芏荡荻菪萏董蒂蔸蚪蛋蝶蠹袋裆裰褡觌订诋诞读谍谛谠豆貂贷赌赕趸跌跺踮踱蹀蹈蹬蹲躲达迨迪迭递逗逮遁道邓邸郸都酊钉钓钝钿铎铞铤铥铫锝锭锻镀镝镦镫队阽陡雕靛靼鞑顶顿颠骶髑鲷鲽鸫黛黩鼎";  arrInitialChart[4]="二佴俄儿厄呃唔嗯噩垩娥婀尔屙峨恩恶愕扼摁洱珥而耳腭苊莪萼蒽蛾讹诶谔贰轭迩遏鄂铒锇锷阏颚额饵饿鲕鳄鸸鹅鹗";  arrInitialChart[5]="丰乏付份仿伏伐俘俯俸偾傅冯凡凤凫分副匐匪反发吠否吩呋咐唪啡坊坟垡复夫奉奋妃妇妨孚孵富封峰帆幅幞幡府废弗忿怫悱愤房扉扶抚拂拊攵放敷斐斧方服枋枫桴梵棼榧樊氛氟汾沣沸法泛浮涪淝滏瀵烦烽焚燔父犭犯狒珐甫畈番疯痱矾砜砝砩祓福稃符筏篚粉粪繁纷纺绂绋绯缚缝缶罘罚翡翻肤肥肪肺腐腑腓腹舫艴芙芬芳芾苻范茯莩菔菲葑蕃藩蘩蚨蜂蜉蜚蝠蝮袱覆讣讽访诽负贩费赋赙赴趺跗蹯辅辐返逢邡郛酆酚釜钒钫锋镄阀阜防附霏非风飞饭馥驸鲂鲋鲱鲼鳆麸黻黼鼢";  arrInitialChart[6]="丐个乖亘估伽佝供倌光公共关冈冠刚刮刽刿剐割功勾匦卦古各告呙呱呷咕咣咯哏哥哽哿嗝嘎嘏噶固国圪圭坩垓垢埂埚塥够妫姑媾孤宄官宫寡尕尜尬尴岗岣崞崮工巩帼干广庋庚弓彀归怪恭惯感戆戈戤拐拱挂掴掼搁搞搿擀改攻故敢旮旰晷更杆杠杲构果枸柑柜根格桂桄桧梏梗棍棺椁概槁槔橄歌毂汞汩沟沽泔涫淦港溉滚澉灌炅牯牿犷狗猓珙瑰瓜甘疙疳痼癸皈皋盖盥睾瞽矸硅硌磙秆稿竿笱筻箍管篙篝簋糕纥纲绀给绠绲缑缟缸罐罟罡羔羹耕耿聒肛肝股肱胍胱胳膈膏臌舸艮苟苷茛莞菇菰葛藁虢虼蚣蛄蛊蜾蝈衮袼裹褂观规觏觚觥诂诖诟诡该诰谷贡购贯贵赅赓赣赶跟跪躬轨轱辊辜过逛遘郜郭酐酤钆钙钢钩钴铬锅锆锢镉镐闺阁陔隔雇革鞲顾馆馘骨骼高鬲鬼鲑鲠鲧鲴鳏鳜鸪鸹鸽鹘鹳鼓龚龟";  arrInitialChart[7]="乎互亥亨伙会何侯候冱凰函划劐劾化卉华厚号合后含吼呵呼和咴哄哈哕哗哼唤唬唿喉喊喙喝嗥嗨嗬嘿嚆嚎嚯回囫圜坏堠壑壕壶夥奂好婚孩宏宦害寒寰岵幌幻弘弧彗很徊後徨徽忽怀怙恍恒恚恢恨悍悔患惑惚惠惶慌慧憨憾或户戽扈护挥捍换撖撼擐攉斛旱昊昏晃晖晗晦曷杭核桁桓桦槐槲横欢毁毫氦汇汉汗沆沪河泓洄洪洹活浍浑浒浣浩海涣涵涸淮混湖湟溷滑滹漶潢濠瀚灏火灰烀烘烩焊焓焕煌煳狐狠猢猴猾獾环珩珲琥瑚璜瓠画痕痪瘊癀皇皓盍盒砉磺祜祸禾秽笏篁篌簧糇糊红绗绘缋缓缳罕翮翰耗耠肓胡胲航花茴荒荟荤荭荷获菏菡萑葫蒿蕙蕻薅薨藿蘅虍虎虹虺蚝蚶蛔蛤蝗蝴蟥蟪蠖行衡褐觳訇讧讳诃诙话诨诲谎豁豢豪货贺贿赫踝轰轷辉还逅逭遑邗邯郝酣醐醢钬铧铪锪锾镬闳阂阍阖隍隳霍韩顸颃颌颔颢馄骅骇骸骺鬟魂鲎鲩鳇鸿鹄鹕鹤鹱麾黄黉黑鼾";  arrInitialChart[8]="";  arrInitialChart[9]="丌举久九乩井亟交京仅今介件价伎佳佶佼俊俭俱倔借倦倨假偈健僦僬僭僵儆兢具兼冀军决净减几击刭剂剑剞剧剪剿劂加劫劲匠即卷卺厥厩及句叫叽吉君咀咎咭哜唧啾喈嗟嘉噍噘噤嚼囝圾均坚基堇境墼夹奖奸妓妗姐姜姣姬娇娟婕婧嫁嫉孑孓季家寂寄将尖就尽局居届屐屦岌岬峻崛嵇嵴巨己巾廑廴建弪径徼忌急恝悸惊惧憬戋戒戛戟戢截戬扃技抉拒拘拣拮挟挢挤捃捐捡据捷掎掘接掬揪揭搅搛撅攫救教敫敬斤旌既旧晋景晶暨机杰极枧架枷柩柬桀桊桔桕桨桷检棘椐椒楗楫榉榘槿橘橛歼殛毽江汲沮泾洁洎洚津浃浆浇济浚浸涓涧渐湔溅激灸炬炯烬焦煎爝爵牮犄犋犍犟狙狡狷獍獗玑玖珈珏琚瑾甲界畸畿疆疖疚疥疽疾痂痉瘕瘠皆皎皲监眷睑睛睫矍矜矩矫矶硷碣碱礁礓祭禁积秸稷稼稽究窖窘窭竞竟竣竭笄笈笕笳笺筋筠简箕箭籍粳精糨紧纟纠级纪经结绛绝绞绢继绩缄缉缙缣缰缴羁羯翦耩聚肌肩肼胛胫胶脊脚腈腱臼舅舰艰艽节芥芨芰苣苴茎茧茭茳荆荐荚荩莒菁菅菊菌葭蒋蒹蒺蓟蕉蕨蕺藉虮蚧蛟蛱蠲街衿袈裥裾襟见觉觊觐角觖解謇警计讥讦记讲讵诀诘诫谏谨谫谲豇贱贾赆赍赳趼跏距跤践跻跽踞踺踽蹇蹶轿较辑近进迥迦迳迹遽郊郏郡鄄酒酱酵醮醵金鉴钅钜钧钾铗铰锏锔锦锩键锯镌镓镜镢间阄阱阶际降隽集雎霁靖静靳鞠鞫鞯韭颈颉颊飓饥饯饺馑驹驾骄骏骥骱髻鬏鲒鲚鲛鲣鲫鲸鸠鸡鹃鹣鹪鹫麂麇齑龃";  arrInitialChart[10]="亏亢伉佧侃侉侩倥傀克况凯刊刳刻剀勘匡匮卡口叩可吭咔咖咳哐哙哭啃喀喟喹喾嗑困圹坎坑块坤坷垦垮垲堀堪壳夔夸夼奎孔客宽寇尻岢岿崆库康廓开快忾恐恪恳恺悃悝愦愧慨慷戡扛扣扩抗抠括拷挎捆控揆揩旷昆暌枯柯栝栲框棵楷槛款氪渴溃溘炕烤犒狂狯珂琨疴盔看眍眶睽瞌瞰矿砍磕科稞空窟窠窥筐筘筷箜篑糠纩绔缂考聩肯胩胯脍芤苛苦莰葵蒈蒉蒯蔻蚵蛞蝌蝰裉裤诓诳课贶跨跬轲逵邝郐酷醌钪钶铐铠铿锎锞锟锴闶阃阔阚靠颏颗馈馗骒骷髁髋髡魁鲲龛";  arrInitialChart[11]="两临丽乐乱了亮仂仑令伦伶佬例侣俐俚俩俪倮偻傈僚儡六兰冫冷冽凉凌凛列刘利剌力劣励劳勒卢卤卵历厉厘另叻吏吕吝呖呤咙咧哩唠唳啉啦啷喇喱喽嘞嘹噜囵囹坜垃垄垅垆垒埒塄墚奁姥娄娈娌婪嫘嫠孪寥寮尥屡履岚岭峦崂崃嵝嶙帘庐廉廊廖廪录律徕怜恋愣懒懔戮戾抡拉拎拢拦挛捋捞捩掠掳揽搂摞撂撩撸擂敛斓料旅旒旯晾朗李来林枥柃柳栊栌栎栏栗栳栾梁梨棂棱椋椤楝楞楼榄榈榔榴橹檑檩殓氇氯沥沦泐泠泪泷泸泺洌洛流浏浪涝涞涟淋渌溜溧滤滥滦漉漏漓漤漯潋潞潦澜澧濂濑灵炉炼烂烈烙熘燎牢犁狸狼猁猎猡獠率玲珑珞琅理琉琏琳璃璐瓴留略疗疠疬痢痨瘌瘘瘤瘰癃癞睐瞵砬砺砻砾硫碌磊磷礼禄离稂稆窿立笠笼箩篓篥篮篱簏籁类粒粝粮粱粼累纶练络绫绺绿缆缕缡缧缭罗罱罹羚羸翎老耒耢耧聆聊聋联肋胧胪脔脶脸腊膂膦臁舻良芦苈苓茏荔荦莅莉莨莱莲菱萝落蒌蒗蓝蓠蓼蔹蔺蕾藜虏虑蛉蛎蜊蜡蝼螂螺蠃蠊蠡裂裢裣裸褛褴览詈论诔谅谰赁赂赉赖趔跞路踉躏躐轮轳轹辂辆辘辚辣辽连逦逯逻遛遴邋邻郎郦酃酪酹醪醴里量銮鎏钌铃铑铝铹铼链锂锊锍锒锣镂镏镙镣镥镧镭镰闾阆阑陆陇陋陵隆隶雒雳零雷霖露靓颅领馏驴骆骊骝骡髅鬣魉鲁鲈鲡鲢鲤鲮鳓鳞鳢鸬鸾鹂鹨鹩鹭鹿麓麟黎黧龄龙";  arrInitialChart[12]="么买亩仫们侔免冒冕冥劢勉勐募卖卯名吗呒命咩咪哞唛喵嘛嘧坶埋墁墓墨妈妙妹姆娩媒媚嫫嬷孟宓密寐寞岷峁嵋帽幂幔幕庙弥弭忙悯愍慕慢懋懑懵扪抹抿拇描摩摸摹敉敏旄明昧昴暝暮曼朦木末杩杪枚某梅梦棉楣模檬殁母每毛毪民氓汨沐沔没沫泌泖泯浼淼渑渺湄湎溟满漠漫漭灭焖煤熳牟牡牦牧犸猕猛猫猸玛玟玫珉瑁甍瘼皿盟目盲眄眇眉眠眯眸睦瞀瞄瞑瞒瞢矛码硭磨礞祢秒秘秣穆篾米糜糸縻绵缅缈缗缦缪美耄耱脉脒腼膜艋艨芈芒苗苜苠茂茅茆茉茗茫荬莓莫莽萌蒙蓦蔑蔓藐蘑蘼虻蚂蛑蛮蜜蜢蝥螟螨蟆蟊蟒蠓蠛袂袤觅谋谜谟谧谩谬貉貊貌貘贸迈迷邈邙酩酶醚鍪钔钼铆铭锚锰镁镅镆镘门闵闷闽陌霉霾靡面鞔颟馍馒马骂髦魅魔鳗鳘鸣鹋鹛麋麦麻麽默黾";  arrInitialChart[13]="乃乜伲佞你侬倪傩内农凝努匿南呐呢呶咛哝哪啮喃喏嗫囊囔囡坭垴埝奈女奴奶妞妮娘娜嫩嬲孥孬孽宁尼尿年廾廿弄弩念忸怒怩恁恧恼您懦扭拈拗拟拧拿挠挪捏捺捻搦撵攮旎昵暖曩柠柰楠氖泞泥浓涅淖溺牛狃狞猊猱瑙甯男疟睨硇碾糯纳纽耐耨聂聍肭胬能脑脓脲腩腻臬艿茑萘蔫蘖虐蛲蝻衄衲袅讷诺赧蹑辇逆那酿钕钠钮铌铙锘镊镍镎闹陧难霓颞馁馕驽鲇鲵鲶鸟黏鼐";  arrInitialChart[14]="î偶呕哦噢怄欧殴沤瓯耦藕讴鸥";  arrInitialChart[15]="丕丿乒乓仆仳佩俜俳偏僻冖凭判刨剖剽劈匍匏匹叛叵呸咆品哌啤啪喷嘌嘭噗噼圃圮坡坪坯埔埤培堋姘娉婆媲嫔嫖屁屏帔帕平庀庖庞彭彷徘怕怦扑批抛抨披拍拚拼捧掊排撇擗攀攴旁旆普曝朋朴杷枇枰棚榀殍毗氆氕沛泡泮泼派浦淠湃湓溥滂漂潘澎濮炮烹爬爿片牌牝犏狍珀琵琶璞瓢瓶甓畔疱疲痞癖皤皮盆盘盼睥瞟瞥砒砰破硼碰磐票笸筢篇篷粕纰缥罴翩耙耪聘胖胚胼脬脯脾膨芘苤苹莆菩萍葡葩蒎蒲蓬蚍蜱螃螵蟛蟠袍袢裒裴襻譬评谝谱貔贫赔趴跑蹁蹒蹼辔辟迫逄邳郫鄱配醅钋钯钷铍铺锫镤镨陪陴霈霹颇频颦飘骈骗魄鲆鹏鼙";  arrInitialChart[16]="七且丘乔乞乾亓亲仟企佥侨侵俅俏倩倾全其凄切券前劁劝劬勤匚区千却卿去取吣启呛嗪嘁噙器囚圈圊圻堑墙奇契妻妾娶嫱寝屈屺岂岍岐岖峤峭崎嵌巧巯庆弃强怯恰悄悛悫悭情惬愀愆慊憔憩戕戗戚扦抢拳挈掐掮揿搴撬擎擒敲旗晴曲朐期权杞枪柒栖桤桥棋椠楸榷槭樯樵橇檎檠欠欺歉歧氍气氢氰求汔汽沁沏泅泉泣洽浅淇清渠湫溱漆潜炔炝牵犬犰球琦琪琴琼璩畎畦痊瘸癯瞧瞿砌硗确碛磬磲祁祈祛祺禽秋秦穷穹窃窍筇筌签箐箝箧糗綦綮绮绻缱缲缺罄羌羟群翘耆肷脐腔芊芑芡芩芪芹苘茄茕茜荃荞荠萁萋葜葺蔷蕖蕲蘧虔虬蚯蛆蛐蛩蛴蜞蜣蜷蜻蝤螓蠼衢衾袷裘裙褰襁觑謦讫诎诠诮请谦谯谴赇起趄趋趣跄跫跷蹊躯轻辁迁迄逑逡遒遣邛邱郄酋醛銎钎钤钦钱钳铅铨锓锖锲锵锹镪阒阕阙阡雀青鞒鞘顷颀颧驱骐骑骞髂鬈鲭鳅鳍鸲鹊麒麴黔黢黥鼽齐龋";  arrInitialChart[17]="乳人仁仍仞任偌儒入冉冗刃嚅嚷壤壬如妊娆孺容嵘弱忍惹戎扔扰揉攘日朊枘染柔桡榕汝洳润溶溽濡热然熔燃狨瑞瓤睿禳稔穰箬糅纫绒绕缛肉肜芮苒若茸茹荏荛荣蓉蓐蕊蕤薷蚋蚺蝾融蠕衽褥襦认让蹂轫软辱铷锐闰阮鞣韧颥饪饶髯";  arrInitialChart[18]="三上世丝丧丨书事什仕仨伞伤伸伺似佘使侍俗俟倏傻僧僳兕兽凇凵删刷剩劭势勺匙十卅升厍厦厮厶叁双叔受叟史司吮呻咝哂哨唆唢售唰唼商啥啬善嗉嗍嗓嗖嗜嗣嗦嗽嗾嘶噬噻四圣垧埏埘埽塑塞塾墅墒士声夙失奢妁始姒姗姝娑娠婶嫂嬗孀孙孰守宋实审室寺寿射少尚尸屎属山岁崧嵊嵩巳市帅师庶式弑彡忄忪怂思恃恕悚愫慎慑戍所扇手扫抒拭拴拾挲捎损授搔搜搠搡摄摅摔撒撕擅擞收散数斯施时是晌晒晟暑曙朔术杀杉杓束松枢柿栅树栓桑桫梢梭梳森椹榫槊歃死殇殊殳毵毹氏水氵汕汜沈沙沭泗洒涉涑涩涮淑淞深渖渗湿溯溲滠漱潲潸澌澍濉灬炻烁烧煞煽熟熵燧爽牲狩狮狲狻猞珊琐瑟甚生甥甩申畲疋疏疝痧瘙瘦盛省眚眭睃睡睢瞍瞬矢矧石砂砷硕碎磉示礻社祀神祟私秫稍税稣穑穗竖竦笋笙笥筛筮筲算簌粟糁素索纱纾绅绍绥绱绳绶缌缩缫缮署羧耍耜耸肃肆肾胂胜脎腧腮膳膻臊舌舍舐舒舜舢艄艏艘色芍芟苏苫荪荽莎莘莳菘菽萨葚蒜蒴蓍蓑蔌蔬薮薯虱虽蚀蛇蛳蛸蜀蜃螋螫蟀蟮衫衰裟裳视觞觫誓讪讼设识诉试诗诜说诵谁谂谇谡谥豕贳赊赎赏赛赡赦跚身轼输述送适逝速遂邃邵鄯酥酸酾释钐铄铈铩铯锁锶锼闩闪陕隋随隧隼霎霜韶顺颂颡飒飕食飧饣饰饲馊馓首驶驷骚骟髓鲥鲨鲺鳃鳋鳝鸶麝黍鼠";  arrInitialChart[19]="乇亭他仝体佗佟佻倘倜停偷傥僮兔冂凸剃剔厅台叹同吐吞听呔唐唾啕啼嗵嚏团囤图土坍坛坦坨堂堍塌塔塘填天太头套她妥婷它屉屠屯帑帖庭庹廷彖彤徒忐忑忒忝态恬恸悌惕慝扌托投抟抬拓拖挑挞挺捅掏探推掭提搪摊昙暾替条柁柝桃桐桶梃梯棠椭榻樘橐檀殄毯氽汀汤汰沓沱泰洮涂涕涛淌淘添湍溏溻滔滕滩潭潼炭炱烃烫焘煺特獭瑭甜田畋疃疼痛痰瘫眺瞳砣砼碳祧秃突窕童笤筒箨粜糖统绦绨缇羰耥肽胎脱腆腾腿膛臀舔艇苔苕茼荼莛菟萄萜葶薹藤蜓蜕蜩螗螳袒裼褪覃誊讨调谈谭豚贪贴趟趿跆跎跳踏踢蹄蹋躺迢退逃透途逖通遢邰郯酞酡酮酴醍醣钍钛钭钽铁铊铜铴铽锑锬镗闼阗陀陶霆韬颓题餮饕饧饨驮驼骀骰髫鲐鲦鳎鸵鹈鼍鼗龆";  arrInitialChart[20]="";  arrInitialChart[21]="";  arrInitialChart[22]="万丸为乌五亠亡仵伍伟伪位佤侮倭偎兀刎剜务勿午卧卫危吴吻吾呜味哇唯喂喔嗡囗围圬坞外妄妩委威娃娓娲婉婺完宛寤尉尾屋崴嵬巍巫帏帷幄庑弯往微忘忤怃悟惋惘惟慰戊我挖挝挽捂握文斡无旺晚晤望未杌枉桅梧武歪毋污汪汶沃沩洧洼浯涠涡渥温渭湾潍炜烷焐煨物牾猥猬王玩玮琬璺瓦瓮畏畹痦痿瘟皖硪碗稳窝紊纨纬纹维绾网罔翁肟胃脘腕腽舞艉芄芜芴苇莴菀萎葳蓊蔚蕹薇蚊蛙蜈蜗蜿袜诬误诿谓豌軎辋迕违逶邬鋈钨问闱闻阌阢隈隗雯雾韦韪顽骛魍魏鲔鹉鹜鼯龌";  arrInitialChart[23]="下习乡些享亵仙休侠信修偕像僖儇兄先兮兴写冼凶刑削勋勖勰匈匣协卸厢县叙吁向吓吸咸咻响哓哮唏啸喜喧嗅嘘嘻噱嚣囟圩型埙墟夏夕奚姓娴婿媳嫌嬉孝学宣宪宵宿寻小屑屣岘岫峋峡崤巡巷巽希席幸序庠庥廨弦彐形徇徐徙循心忻性恂恤息悉悬悻惜想惺懈戌戏掀揎携撷擤效斜新旋旬旭昔昕星显晓晰暄暇暹曛曦朽杏析枭枵柙校栩械楔楦榍榭樨橡檄欣欷歆歇歙殉氙汐汛汹泄泫泶泻洗洫洵浔浠消涎淅淆渫渲湘溆溪溴漩潇瀣炫烯煊煦熄熊熏熙熹燮燹牺犀狎狭猃猩献獬獯玄现玺瑕璇痃痫癣皙盱相眩瞎矽硎硒硖硝碹祆祥禊禧秀稀穴穸窨笑筅筱箫箱籼粞糈系絮纤线绁细绚绡绣绪续缃缬罅羞羡羲翔翕肖胁胥胸腥腺膝舄舷舾芎芗芯苋荀荇荨莶菥萧萱葙葸蓄蓰蓿蕈薛薤薪薰藓虚虾蚬蜥蝎螅蟋蟓蟹血衅衔袖袭襄西觋训讯许询详诩谐谑谖谢象貅贤跣跹踅躞轩辖辛迅选逊逍遐邂邢邪郇郗酗酰醑醒醯醺鑫铉铣销锈锌锡锨镟镶闲阋陉限险陷隙隰雄雪需霄霞霰靴鞋项须顼飨饩饷馅馐香馨驯骁骧髹魈鲜鲞鲟鳕鸺鹇黠鼷";  arrInitialChart[24]="一与业严丫义乙也予于云亚亦亿仡以仪仰伊优伛伢佑余佚佣佯佾侑依侥俑俞俣俨倚偃允元兖养冤冶刈刖剡劓勇匀医卣印压厌原厣又友右叶吆吖吟吲呀呓员呦咏咦咬咽咿哑哟唁唷喁喑喻嘤噎噫因园囿圄圆圉圯垠垣垭垸域埸堙堰塬墉壅壹夜夤夭央夷奄奕妍妖妤妪姚姨姻娅娱婴媛媵嫣嬴孕宇宜宥宴寅寓尢尤尧尹屹屿岈岩岳峄峪崖崦崾嵛嶷已幺幼幽应庸庾延异弈弋引彝彦影役徉御徭忆忧怏怡怨怿恙恹恽恿悒悠悦愈愉意愚愠愿慵懿扬抑押拥挹掖掩掾揄揖揠援揶摇撄攸於旖昀易映昱晏晔晕曜曰曳月有杨杳柚样桠椅椰楹榆樱樾橼檐欤欲欹殃殒殪殷毅毓氤氧氩氲永沂沅油沿泱泳洇洋浴涌涯液淤淫淹渊渔渝游湮源溢滟滢演漪漾潆瀛瀹炀炎烊烟烨焉焰焱煜熠熨燕燠爰爷爻牖牙犹狁狱狳狺猗猷猿玉珧琊琰瑗瑛瑜瑶璎用甬由疑疡疣疫痈痍痒痖瘀瘐瘗瘾瘿癔盂盈益盐眙眢眼睚矣砑研砚硬禹禺秧移窈窑窬窳竽筵箢粤繇纡约纭绎缘缢缨罂罨羊羽羿翊翌翳翼耀耘耶聿肀肄育肴胤胭胰腋腌腰腴膺臃臆臾舀舁舆舣艳艺芋芫芸芽苑苡英茔茚茵荑荥荧荫药莜莠莸莹莺菸萤营萦萸蓣蓥蕴薏虞蚁蚓蚜蚰蚴蛘蛹蜒蜮蜴蝇蝓蝣螈衍衙衣衤袁裔裕要觎言誉讠议讶译诒诣语诱谀谊谒谕谚谣谳豫贻赝赢越跃踊轶轺辕迂迎运迓远迤逸逾遇遗遥邀邑邕邮邺郁郓郢郧郾鄞鄢酉酏酝酽釉野钇钥钰钺铀铕铘铟铱银镒镛镱闫阅阈阉阎阳阴院陨隅隐雁雅雍雨雩霪靥鞅韫音韵页预颍颐颖颜餍饔饫饮饴馀驭驿验鬻魇鱼鱿鳐鳙鸢鸦鸭鸯鸳鹆鹞鹦鹬鹰黝黟鼋鼬鼹龈龉龠";  arrInitialChart[25]="丈专丬中主之乍ໞ争ા仄仉仔仗仲众伫住佐作侄侏侦俎倬债值做偬兆兹再冢准凿则制助匝卒卓占卮只召吒吱周咂咋咒咤咨咫咱哉哲哳唑唣啁啄啧啭喋喳嘱嘴噪在圳址坐坠埴增壮奏奘妆妯姊姿嫜子字孜孳宅宗宙宰寨尊展峙峥崭崽嵫嶂州左帐帙帚帜帧帻幛幢庄座张彘彰征徵志忠忮怍怎怔总恣惴憎战扎执找抓折拄拙招择拯拶拽指挚挣振捉掌掷揍揸搌摘摭摺撙撞撰擢攒攥支政整斋斟斩斫旃族旨早昃昝昨昭昼智暂最朕札朱杂杖杼枕枝枣枳柘柞柱栀栈栉株栽桌桎桢桩梓棕棹植椎楂榛榨槠樟樽橥止正殖毡汁治沼沾注泽洙洲浈浊浙浞涨涿淄渍渚渣湛滋滓滞漳潴澡濯灶灼灾炙炷炸烛照煮燥爪状狰猪獐珍珠琢璋瓒甄甑甾畛疰疹痄症痔痣瘃瘴瘵皂皱盅盏直真眦眨着睁瞩瞻知砖砟砦砧砸碡磔祉祖祗祚祝祯禚种租秩秭稚稹窀窄窒站章竹竺笊笫笮筑筝箦箴箸篆簪籀籽粘粥粽糌糟紫絷纂纣纵纸组织终绉综绽缀缁缒缜缯缵罩罪置罾翟翥者耔职肇肘肢肫肿胀胄胗胙胝脂脏腙膣臧自至致臻舟舯舳舴芝芷苎茁茱荮菹著葬蒸蓁蔗蕞藻蘸蚤蚱蛀蛛蛭蛰蜇蜘螽蟑衷装褶觜觯訾詹证诅诈诊诌诏诛诤诸诹诼谆谘谪谮谵豸贞责账质贮贼贽赀赃资赈赘赚赜赞赠赭走赵趑趱足趾跖踪踬踯踵躁躅躜轧转轴轵轸载轾辄辎辗辙辶这迮追逐造遭遮遵邹邾郅郑鄣鄹酌酎酢酯醉重錾针钊钟钲钻铡铢铮铸锃锗锥锱锺镇镞镯长闸阝阵阻阼陟陬障隹雉震颛馔驵驺驻骓骘骤髭鬃鲰鲻鳟鸩鸷鹧麈黹齄龇";  var arrNumLetter={"0":"A","1":"B","2":"C","3":"D","4":"E","5":"F","6":"G","7":"H","8":"I","9":"J","10":"K","11":"L","12":"M","13":"N","14":"O","15":"P","16":"Q","17":"R","18":"S","19":"T","20":"U","21":"V","22":"W","23":"X","24":"Y","25":"Z"};  var arrPolyphone={"丁":"DZ","万":"WM","且":"QJ","乐":"YL","乘":"SC","乜":"NM","乾":"QG","亟":"QJ","仇":"QC","仡":"YG","会":"KH","传":"ZC","伺":"SC","伽":"QJG","佃":"TD","佚":"YD","佴":"NE","侗":"TD","侥":"YJ","侧":"CZ","便":"PB","俞":"YS","俟":"SQ","倘":"TC","傀":"KG","其":"QJ","兹":"ZC","冯":"PF","倘":"TC","傀":"KG","其":"QJ","兹":"ZC","冯":"PF","凹":"AW","刨":"PB","券":"XQ","刹":"SC","剡":"YS","剿":"JC","勺":"SB","匙":"SC","匹":"YP","区":"QO","卒":"ZC","单":"SDC","卡":"QK","厂":"CA","厕":"SC","厦":"XS","参":"SC","句":"JG","叨":"TD","召":"ZS","叶":"YX","吁":"YX","合":"HG","吓":"XH","吡":"PB","否":"PF","吭":"KH","呃":"E","呆":"DA","呔":"TD","呕":"O","呲":"ZC","呵":"KHA","咀":"ZJ","咖":"KG","咯":"LKG","咳":"KH","哎":"A","哗":"YH","哦":"WOE","唉":"A","唔":"WN","唬":"XH","啊":"A","喋":"ZD","喏":"RN","喔":"WO","喳":"ZC","嗄":"SA","嗌":"YA","嗒":"TD","嗳":"A","嘏":"JG","嘘":"XS","嘬":"ZC","嘲":"ZC","嘿":"MH","噱":"XJ","嚣":"XA","囝":"NJ","囤":"TD","圈":"JQ","圜":"YH","圩":"XW","圻":"YQ","均":"YJ","坏":"PH","坻":"DC","垌":"TD","埔":"PB","埤":"PB","堆":"ZD","堕":"DH","堡":"PB","塔":"TD","壳":"KQ","夯":"HB","夹":"JG","奇":"QJ","契":"XQ","姥":"ML","娩":"WM","宿":"SX","将":"QJ","尉":"YW","尢":"YW","尾":"YW","尿":"SN","屏":"PB","属":"ZS","屯":"ZT","屹":"YG","峒":"TD","峙":"ZS","峤":"QJ","嵌":"QK","巷":"XH","帱":"DC","幢":"ZC","广":"GA","廑":"QJ","弄":"NL","弹":"TD","强":"QJ","彷":"PF","忪":"ZS","恫":"TD","恶":"WE","悝":"LK","慝":"TN","戆":"ZG","戌":"XQ","戏":"XH","扁":"PB","扒":"PB","扛":"KG","扳":"PB","折":"ZS","拂":"FB","拗":"NA","括":"KG","拽":"ZY","挝":"WZ","挟":"XJ","挨":"A","捱":"A","掸":"SD","掺":"SC","提":"TD","撮":"ZC","攒":"ZC","於":"YW","无":"WM","暴":"PB","曝":"PB","曳":"ZY","曾":"CZ","朝":"ZC","期":"QJ","术":"ZS","杓":"SB","枞":"ZC","枸":"JG","柁":"TD","柜":"JG","查":"CZ","栅":"ZS","栎":"YL","栖":"XQ","栝":"KG","校":"XJ","桧":"HG","椎":"ZC","椹":"ZS","楂":"ZC","楷":"KJ","槛":"KJ","欹":"YQ","歙":"XS","殖":"ZS","氏":"ZS","汤":"TS","沈":"SC","沌":"ZD","沓":"TD","沤":"O","泊":"PB","泌":"MB","泷":"SL","泺":"PL","浅":"QJ","浍":"KH","浒":"HX","浚":"XJ","涌":"YC","涡":"WG","渑":"SM","湫":"QJ","溃":"KH","溱":"ZQ","漯":"TL","澄":"DC","澹":"TD","瀑":"PB","炅":"JG","炔":"QG","炮":"PB","焘":"TD","焯":"ZC","熬":"A","犍":"QJ","率":"SL","玢":"FB","町":"TD","畜":"CX","番":"PF","疋":"YSP","疟":"YN","瘕":"XJ","盛":"SC","省":"SX","瞧":"YQ","瞿":"QJ","矜":"QJG","石":"SD","砉":"XH","硌":"LG","磅":"PB","祢":"NM","祭":"JZ","禅":"SC","种":"ZC","秘":"MLB","稽":"JQ","窨":"YX","筠":"YJ","粘":"ZN","粥":"ZY","系":"XJ","繁":"PF","繇":"ZY","红":"HG","纤":"XQ","纥":"HG","纶":"LG","给":"GJ","绨":"TD","缉":"QJ","缏":"PB","缲":"ZSQ","缴":"JZ","翟":"ZD","耙":"PB","脯":"PF","腊":"XL","腌":"YA","膀":"PB","臭":"CX","般":"BP","舵":"TD","艾":"YA","芒":"WM","芘":"PB","芥":"JG","苎":"ZN","苕":"TS","苣":"QJ","茄":"QJ","茈":"ZC","茜":"XQ","荑":"YT","荠":"QJ","荤":"XH","荥":"YX","荨":"QX","莞":"WG","莩":"PF","菀":"YW","葚":"SR","蔓":"WM","蔚":"YW","蕉":"QJ","藏":"ZC","藓":"XL","虹":"JH","虾":"XH","蚵":"KH","蛇":"YS","蛤":"HG","蛸":"XS","蛾":"YE","蜡":"ZL","蝤":"YQ","螫":"SZ","行":"XH","衰":"SC","袷":"QJ","裨":"PB","裳":"SC","褚":"ZC","覃":"TQ","见":"JX","解":"JX","识":"SZ","说":"YS","诶":"E","调":"TD","谷":"YG","貉":"MH","贾":"JG","趄":"QJ","蹊":"XQ","蹲":"DC","车":"JC","轧":"ZYG","辟":"PB","适":"SK","遗":"YW","邪":"YX","郇":"XH","酢":"ZC","重":"ZC","钯":"PB","钿":"TD","铅":"QY","铛":"DC","铤":"TD","铫":"YD","镐":"HG","镡":"XTC","长":"ZC","阏":"YE","阚":"KH","阽":"YD","阿":"AE","陂":"PB","降":"XJ","陶":"YT","隗":"WK","隹":"ZC","霰":"XS","靓":"LJ","革":"GJ","鞘":"SQ","颈":"JG","颉":"XJ","颌":"HG","颤":"CZ","饧":"XT","驮":"TD","骀":"TD","骠":"PB","髟":"SB","鬲":"LG","魄":"TPB","鲭":"ZQ","鸟":"ND","鹄":"HG","鹘":"HG","麇":"QJ","鼽":"YQ","齐":"QJ","龈":"YK","龟":"QJG"};  /**  * 获得所有结果  * @param str 输入的字符串  * @return 首字母的字符串数组  */  function letterArr(str) {  var res = "";  for ( var i = 0; i < str.length; i++) { // 输入的字符串的每一个字符,作为参数调用checkCh()函数   res += checkCh(str.charAt(i));  }  return res;  }  /**  * 根据输入返回不同值  * @param ch 输入的字符串中的一个字符  * @return 不是汉字(unicode 19968-40869 为汉字),返回原字符  * @return 是汉字且为多音字,返回汉字对应的首字母字符串  * @return 是汉字且不为多音字,调用getCh函数,并返回汉字对应的首字母字符  */  function checkCh(ch) {  var uni = ch.charCodeAt(0);  if (uni > 40869 || uni < 19968){   // 不是汉字,返回原字符   return ch;  }else{   return getCh(ch);  }  }  /**  * 根据汉字所属数组的id获取该汉字的首字母  * @param str 输入的字符串中的一个字符  * @return 字符对应的首字母  */  function getCh(ch) {  var letter = "";  for ( var i = 0; i < arrInitialChart.length; i++) {   if (arrInitialChart[i].indexOf(ch) >= 0) { // 当str在arrInitialChart[i]数组中   letter = arrNumLetter[i]; // letter被赋值arrNumLetter数组对应的字符首字母   }  }  return letter;  } }; </script></html>

这种方法在多种浏览器下可用,绝大部分汉字均可获取其简拼。如果你有更好的实现方法,欢迎分享!!谢谢

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表