获取汉字的首字母
EXCEL-vba中获取汉子拼音首字母
PINYIN BJSXBZZTCDTWZXGMTDKFXM XBJYWCSDTDFKZLXM XBJYWCEDTDFKZLXM XBJYWCSDTDFKZLXM(Y)BJSTBZSTGCZSPXGMTDKFXM JSZXTCWDBJJHZSTDKKXM BJSSJZSJCDPSXGMTDKFXM BJSSLXZYLCSJPPXGMTDKFXM BJSDYZXFCDZBXGMTDKF NYXBJPZXXWCTDZLXM DFXGDXYXCBJLLZTDKFXM BJSDHXJGCGJYKDLBXGMTDKFXM ZCQBJZGXZCHCDKF BJSQXXSKCHCPXGMTDKFXM XBJYYZCTDFKXM(E)XBJYYZCTDFKXM(S)BJSXBZZTCSJBHXGMTDKFXM XXXGCZDSC,XHC,QJC,BJLC,HCD BJSHZJZXCCMZSXGMTDKFXM BJSDYZGFCQGPXGMTDKF BJSTBZXWCHNBYKXGMTDKFXM BJSSLXZYFCZJYDXGMTDKFXM BJSLSZLSPCMWTXGMTDKFXM BJSLSZLHCMYPXGMTDKFXM BJSDHXQGCMSKXGMTDKFXM BJSASXXKCHSPXGMTDKF BJSSLXZYLCGJPPXGMTDKFXM BJSSLXZYLCDJMTXGMTDKFXM BJSDYZHTCYPDSXGMTDKF BJSQXXXRCJDSXGMTDKFXM BJSASXTZCZJPXGMTDKF BJSDYZHTCXSBXGMTDKF BJSQXXFLCHYSDXGMTDKFXM BJSSJZSJCSNDXGMTDKFXM BJSBZZZZCDSCXGMTDKFXM HYSBSXDZCBBJQTTDKFXM WNSLWQNSXNMCBJZTDKFXM BJSXBZHWCGJWXGMTDKFXM BJSXBZHWCHGGXGMTDKFXM BJSXBZSTCSJWXGMTDKFXM BJSXBZSTCBBSXGMTDKFXM BJSXBZSTCLJWXGMTDKFXM BJSXBZZTCMFXGMTDKFXM BJSQXXFLCFJDXGMTDKFXM BJSDYZHTCCDXGMTDKFBJSDYZYQCHLSXGMTDKF BJSCCBZHSCXDKXGMTDKFXM BJSCCBZZGCGJDDGMTDKFXM BJSTBZXWCPZSXGMTDKFXM BJSTBZSTGCZJDPZXGMTDKFXM XBJYWCLDTDFKZLXM(E)XBJYQCWDTDFKZLXM XBJYBCYDTDFKZLXM XBJYNKSTDFKZLXM XBJYBCYDTDFKZLXMY XBJYNKSTDFKZLXMY XBJYLCLDTDFKZLXM XBJYWCLDTDFKZLXM BJSHGTZDBCYZZXGMTDKFXM BJSHGTZDBCHLZXGMTDKFXM BJSHGTZXHCYJFXGMTDKFXM BJSHGTZXHCBFSXGMTDKFXM BJSXBZSTCXLSXGMTDKFXM BJSQXXFLCWJDPXGMTDKFXM BJSXBZSTCDMPXGMTDKFXM BJSSLXZSLCMGDLBXGMTDKFXM GDXXHZBJMCTDFK(Y)YJZZXDBXBJCTDKFXM BJSASXZZCJZZHJDWZXGMTDKF BJSSLXZYFCJJPZXGMTDKFXM XBJYQCSDTDFKZLXM BJSQXXXRCWLSXGMTDKFXM BJSDYZXFCWPFPZXGMTDKF BJSDYZXFCWJFPZXGMTDKF BJSQXXXRCWLSSXGMTDKFXM BJSDYZXFCSJFXGMTDKF BJSSLXZLFCDTLZXGMTDKFXM BJSDYZXFCCKTXGMTDKF BJSDYZXFCGJFXGMTDKF HYXBJZQGHPZDQTQFK BJSTBQZZXCGBXGMTDKFXM BJSDHXJGCDHSXGMTDKFXM BJSDHXLLCDDEXGMTDKFXM BJSLSZXZCYJPXGMTDKFXM BJSLSZXZCLJDDXGMTDKFXM BJSLSZXZCZZLXGMTDKFXM BJSLSZSNTCWJBHXGMTDKFXM BJSLSZLSPCMCBHXGMTDKFXM BJSLSZLHCSLPXGMTDKFXM BJSDHXQGCMBPXGMTDKFXM BJSCHZMLCLFYXGMTDKFXM BJSGLZGLCDPPXGMTDKFXMBJSCHZMLCSYZYSBXGMTDKFXM BJSCHZSHCSZCSXGMTDKFXM BJSCHZTFCBZJTBBXGMTDKFXM BJSHZJZPJZCSCYKXGMTDKFXM BJSHZJZXCCGJLXGMTDKFXM BJSHZJZXCCLTWXGMTDKFXM BJSHZJZHYCYJWXGMTDKFXM BJSBZZYKCBRCXGMTDKFXM BJSBZZZCCHJFXGMTDKFXM BJSBZZZCCYJXGMTDKFXM BJSBZZDXCMZSXGMTDKFXM BJPZYQCTDZLXM BJSXBZHWCMBAXGMTDKFXM XBJYLCSDTDFKZLXM BJZWACJCZFKZLXM BJSQXXSKCXHPXGMTDKFXM BJSQXXSKCWPFXGMTDKFXM BJSQXXSKCZJFXGMTDKFXM BJSQXXSKCGDYKXGMTDKFXM BJSDPZSBCSBDLCXGMTDKFXM BJSDPZLHCDWZXGMTDKFXM BJSDPZGMCDPZXGMTDKFXM BJSDPZZXCDLCXGMTDKFXM BJSDPZSBCMCPXGMTDKFXM BJSHGTZDPZCDHZPDXGMTDKFXM BJSHGTZDPZCSPEDXGMTDKFXM BJSHGTZDBCZCBHXGMTDKFXM BJSHGTZANZCDMTXGMTDKFXM WAXBJZJXC、SKXMGCTDKFXM XBJYWCSDTDFKZLXM(E)XBJYWCSDTDFKZLXM(S)XBJYWCWDTDFKZLXM XBJYWCBDTDFKZLXM BJSTBQZDZSCSZYXGMTDKFXM BJSTBQZWYSCYBBXGMTDKFXM BJSTBQZWYSCDPLJDDXGMTDKFXM BJSTBQZWYSCDPMJDDXGMTDKFXM BJSQXXZTCMZGYXGMTDKFXM BJSQXXFLCTLSYKXGMTDKFXM BJSQXXFLCHSDXGMTDKFXM BJSSJZDZCNCXGMTDKFXM BJSDYZXFCLJWXGMTDKF BJSTBZXJCLJDTXGMTDKFXM XBJYYZCTDFKXM(Y)XBJYWCLDTDFKZLXM(Y)LNSDDSDGSBJZ、MJDZTDZLXM XBJYQCEDTDFKZLXMBJSASXYKTCZJBHXGMTDKF BJSDYZGFCMMSXGMTDKF BJSSJZSJCMJDXGMTDKFXM BJSDYZGFCXXSXGMTDKF BJSDYZGFCDJFXGMTDKF BJSDYZGFCZJFXGMTDKF BJSSLXZSLCMCBXGMTDKFXM BJSSLXZSLCAZYXGMTDKFXM BJSSJZSJCHBTXGMTDKFXM BJSDYZGFCDSXGMTDKF GDXXHZBJMCTDFK(E)BJXMGZTDZLXM CHXBJXXFCCTDFKZLXM BJSLSZSNTCLSSXGMTDKFXM BJSDHXGDHCSGJXGMTDKFXM XXXBLTZBJBCHCDKF2007.159 BJSDHXKLCLJDLBXGMTDKFXM BJSDHXLLCDLBXGMTDKFXM NBJJKFQBHZXBJIIQTDKFXM BJSQXXSKCSDWXGMTDKFXM BJSASXMLCLJDSXGMTDKF BJSDYZHTCHSWXGMTDKF BJSSLXZLFCYJFXGMTDKFXM BJSDYZHTCBJPZXGMTDKF BJSQXXQLGCDPZXGMTDKFXM BJSSLXZLFCSGZXGMTDKFXM BJSDYZHTCPZXGMTDKF BJSASXMWCXTLXGMTDKF BJSQXXQLGCSLPXGMTDKFXM BJSSLXZCYCSLXGMTDKFXM BJSQXXQLGCGDSXGMTDKFXM BJSDYZMWCMASXGMTDKF BJSLSZXZCDHPZXGMTDKFXM AHSLQXFXJXBJLCXYZTDFKXM YCSBJZHPCGYLBCGDXM(Y2010-1)BJSHGTZANZCSGXGMTDKFXM BJSHGTZDPZCWJWZXGMTDKFXM BJSXBZHWCMJXGMTDKFXM BJSXBZZTCMYSXGMTDKFXM BJSXBZHWCSZYKXGMTDKFXM BJSXBZHWCZJFXGMTDKFXM BJSXBZZTCDPXGMTDKFXM BJSXBZZTCWZTXGMTDKFXM LZXLJZ、BJXTDCBGDXM BJSDYZYQCSLPPXGMTDKF ZYSMLXSBJBNTZLXMYCZCJYCJBJBNTZLXM LCXHBZBJCTDFKXM BJXQSXMWCTDZLXMJBXX_XMMC毕节市小坝镇中屯村大塘湾子小规模土地开发项目襄北监狱五场三队土地复垦整理项目襄北监狱五场二队土地复垦整理项目襄北监狱五场四队土地复垦整理项目(一)毕节市田坝镇沙炭沟村钟山坡小规模土地开发项目界首镇兴田村委第八经济合作社土地开垦项目毕节市生机镇生机村大坡上小规模土地开发项目毕节市撒拉溪镇杨柳村孙家皮坡小规模土地开发项目毕节市大银镇新丰村打荞坝小规模土地开发宁远县柏家坪镇小新屋村土地整理项目大方县高店乡营兴村保鸡落梁子土地开发项目毕节市大河乡鸡姑村高家丫口大老包小规模土地开发项目周村区北郊镇固玄庄村荒草地开发毕节市千溪乡沙垮村花厂坪小规模土地开发项目襄北监狱养殖场土地复垦项目(二)襄北监狱养殖场土地复垦项目(三)毕节市小坝镇中屯村苏家背后小规模土地开发项目西乡县高川镇大树村,薛河村,前进村,八角楼村,荒草地开发2005.31毕节市海子街镇西冲村梅子山小规模土地开发项目毕节市大银镇高峰村青杠坪小规模土地开发毕节市田坝镇兴旺村黄纳坝丫口小规模土地开发项目毕节市撒拉溪镇永丰村朱家岩洞小规模土地开发项目毕节市梨树镇梨树坪村麻窝头小规模土地开发项目毕节市梨树镇联合村庙右坡小规模土地开发项目毕节市大河乡青杠村木梳块小规模土地开发项目毕节市阿市乡雄垮村火烧坡小规模土地开发毕节市撒拉溪镇杨柳村顾家皮坡小规模土地开发项目毕节市撒拉溪镇杨柳村邓家麻塘小规模土地开发项目毕节市大银镇黄塘村窑坪大山小规模土地开发毕节市千溪乡兴荣村叫点山小规模土地开发项目毕节市阿市乡头庄村曾家坡小规模土地开发毕节市大银镇黄塘村谢山包小规模土地开发毕节市千溪乡法朗村火焰山顶小规模土地开发项目毕节市生机镇生机村杀牛洞小规模土地开发项目毕节市八寨镇钟寨村大石场小规模土地开发项目华阴市北社乡东栅村坝北九区滩涂地开发项目渭南市临渭区南师乡南马村卞家组土地开发项目毕节市小坝镇河尾村郭家湾小规模土地开发项目毕节市小坝镇河尾村河拐拐小规模土地开发项目毕节市小坝镇水塘村沈家湾小规模土地开发项目毕节市小坝镇水塘村包包上小规模土地开发项目毕节市小坝镇水塘村刘家湾小规模土地开发项目毕节市小坝镇中屯村墓坟小规模土地开发项目毕节市千溪乡法朗村樊家地小规模土地开发项目毕节市大银镇黄塘村川洞小规模土地开发毕节市大银镇羊桥村猴老山小规模土地开发毕节市长春堡镇滑石村硝洞口小规模土地开发项目毕节市长春堡镇垭关村官家大地规模土地开发项目毕节市田坝镇兴旺村坪子上小规模土地开发项目毕节市田坝镇沙炭沟村朱家大坪子小规模土地开发项目襄北监狱五场六队土地复垦整理项目(二)襄北监狱七场五队土地复垦整理项目襄北监狱八场一队土地复垦整理项目襄北监狱农科所土地复垦整理项目襄北监狱八场一队土地复垦整理项目一襄北监狱农科所土地复垦整理项目一襄北监狱六场六队土地复垦整理项目襄北监狱五场六队土地复垦整理项目毕节市何官屯镇大坝村岩嘴嘴小规模土地开发项目毕节市何官屯镇大坝村横梁子小规模土地开发项目毕节市何官屯镇新华村余家坟小规模土地开发项目毕节市何官屯镇新华村宝峰寺小规模土地开发项目毕节市小坝镇水塘村小岭上小规模土地开发项目毕节市千溪乡法郎村王家大坡小规模土地开发项目毕节市小坝镇水塘村洞门坡小规模土地开发项目毕节市撒拉溪镇沙乐村毛狗洞老包小规模土地开发项目广德县新杭镇百家庙村土地复垦(一)印江自治县刀坝乡白金村土地开发项目毕节市阿市乡中寨村旧寨组何家洞湾子小规模土地开发毕节市撒拉溪镇永丰村金家坪子小规模土地开发项目襄北监狱七场三队土地复垦整理项目毕节市千溪乡兴荣村望朗石小规模土地开发项目毕节市大银镇新丰村王婆坟坪子小规模土地开发毕节市大银镇新丰村汪家坟坪子小规模土地开发毕节市千溪乡兴荣村望朗石山小规模土地开发项目毕节市大银镇新丰村申家坟小规模土地开发毕节市撒拉溪镇龙凤村大塘梁子小规模土地开发项目毕节市大银镇新丰村刺枯塘小规模土地开发毕节市大银镇新丰村关家坟小规模土地开发怀远县包集镇清沟河潘圩段弃土区复垦毕节市田坝桥镇螃蟹村沟边小规模土地开发项目毕节市大河乡鸡姑村大火山小规模土地开发项目毕节市大河乡拉罗村洞洞儿小规模土地开发项目毕节市梨树镇新寨村余家坡小规模土地开发项目毕节市梨树镇新寨村罗家大地小规模土地开发项目毕节市梨树镇新寨村桦槁林小规模土地开发项目毕节市梨树镇水牛屯村武家背后小规模土地开发项目毕节市梨树镇梨树坪村煤场背后小规模土地开发项目毕节市梨树镇联合村杉林坡小规模土地开发项目毕节市大河乡青杠村马豹坪小规模土地开发项目毕节市岔河镇木来村漏风丫小规模土地开发项目毕节市戈乐镇戈乐村大偏坡小规模土地开发项目毕节市岔河镇木来村十一组圆山包小规模土地开发项目毕节市岔河镇双华村三组茶山小规模土地开发项目毕节市岔河镇塘丰村八组积塘包包小规模土地开发项目毕节市海子街镇彭家寨村三叉丫口小规模土地开发项目毕节市海子街镇西冲村公鸡岭小规模土地开发项目毕节市海子街镇西冲村烂田湾小规模土地开发项目毕节市海子街镇红堰村扬家湾小规模土地开发项目毕节市八寨镇岩口村帮人场小规模土地开发项目毕节市八寨镇中厂村韩家坟小规模土地开发项目毕节市八寨镇中厂村营脚小规模土地开发项目毕节市八寨镇大兴村苗子山小规模土地开发项目北集坡镇阳泉村土地整理项目毕节市小坝镇河尾村毛稗凹小规模土地开发项目襄北监狱六场四队土地复垦整理项目北极镇旺安村旧村庄复垦整理项目毕节市千溪乡沙垮村小黄坡小规模土地开发项目毕节市千溪乡沙垮村王婆坟小规模土地开发项目毕节市千溪乡沙垮村张家坟小规模土地开发项目毕节市千溪乡沙垮村古洞丫口小规模土地开发项目毕节市对坡镇石板村石板大老厂小规模土地开发项目毕节市对坡镇乐海村大窝子小规模土地开发项目毕节市对坡镇嘎木村大坪子小规模土地开发项目毕节市对坡镇中心村大老厂小规模土地开发项目毕节市对坡镇石板村毛草坪小规模土地开发项目毕节市何官屯镇大坪子村大海子平地小规模土地开发项目毕节市何官屯镇大坪子村山瓢儿地小规模土地开发项目毕节市何官屯镇大坝村猪场背后小规模土地开发项目毕节市何官屯镇阿哪寨村大麻塘小规模土地开发项目万安县百加镇九贤村、韶口乡梅岗村土地开发项目襄北监狱五场四队土地复垦整理项目(二)襄北监狱五场四队土地复垦整理项目(三)襄北监狱五场五队土地复垦整理项目襄北监狱五场八队土地复垦整理项目毕节市田坝桥镇店子上村狮子岩小规模土地开发项目毕节市田坝桥镇弯腰树村圆包包小规模土地开发项目毕节市田坝桥镇弯腰树村大坡李家大地小规模土地开发项目毕节市田坝桥镇弯腰树村大坡糜家大地小规模土地开发项目毕节市千溪乡中屯村苗子滚岩小规模土地开发项目毕节市千溪乡法朗村糖梨树丫口小规模土地开发项目毕节市千溪乡法朗村黄沙地小规模土地开发项目毕节市生机镇大寨村牛场小规模土地开发项目毕节市大银镇新丰村罗家湾小规模土地开发毕节市田坝镇先进村罗家大塘小规模土地开发项目襄北监狱养殖场土地复垦项目(一)襄北监狱五场六队土地复垦整理项目(一)辽宁省丹东市东港市北井子、马家店镇土地整理项目襄北监狱七场二队土地复垦整理项目保靖县大妥乡甘溪村土地复垦项目毕节市阿市乡丫口田村郑家背后小规模土地开发毕节市大银镇高峰村冒冒山小规模土地开发毕节市生机镇生机村梅家地小规模土地开发项目毕节市大银镇高峰村星秀石小规模土地开发毕节市大银镇高峰村丁家坟小规模土地开发毕节市大银镇高峰村朱家坟小规模土地开发毕节市撒拉溪镇双龙村茅草坝小规模土地开发项目毕节市撒拉溪镇双龙村凹子岩小规模土地开发项目毕节市生机镇生机村河坝头小规模土地开发项目毕节市大银镇高峰村大山小规模土地开发广德县新杭镇百家庙村土地复垦(二)保靖县毛沟镇土地整理项目淳化县卜家乡西奉村村土地复垦整理项目毕节市梨树镇水牛屯村螺丝山小规模土地开发项目毕节市大河乡官代河村山根脚小规模土地开发项目西乡县白龙塘镇白家坝村荒草地开发2007.159毕节市大河乡柯罗村刘家大老包小规模土地开发项目毕节市大河乡拉罗村大老包小规模土地开发项目南堡经济开发区滨海镇西北街II区土地开发项目毕节市千溪乡沙垮村沙地弯小规模土地开发项目毕节市阿市乡木拉村刘家大山小规模土地开发毕节市大银镇黄塘村火石湾小规模土地开发毕节市撒拉溪镇龙凤村杨家坟小规模土地开发项目毕节市大银镇黄塘村百家坪子小规模土地开发毕节市千溪乡千朗沟村大坪子小规模土地开发项目毕节市撒拉溪镇龙凤村三锅庄小规模土地开发项目毕节市大银镇黄塘村坪子小规模土地开发毕节市阿市乡麻窝村谢土岭小规模土地开发毕节市千溪乡千朗沟村松林坡小规模土地开发项目毕节市撒拉溪镇朝营村松林小规模土地开发项目毕节市千溪乡千朗沟村鬼打山小规模土地开发项目毕节市大银镇木瓦村马鞍山小规模土地开发毕节市梨树镇新寨村大汗坪子小规模土地开发项目安徽省临泉县范兴集乡半截楼村小于庄土地复垦项目阳春市八甲镇黄坡村果园岭补充耕地项目(阳2010-1)毕节市何官屯镇阿哪寨村深沟小规模土地开发项目毕节市何官屯镇大坪子村文家湾子小规模土地开发项目毕节市小坝镇河尾村庙脚小规模土地开发项目毕节市小坝镇中屯村蚂蚁山小规模土地开发项目毕节市小坝镇河尾村狮子丫口小规模土地开发项目毕节市小坝镇河尾村赵家坟小规模土地开发项目毕节市小坝镇中屯村大坡小规模土地开发项目毕节市小坝镇中屯村湾子头小规模土地开发项目临猗县临晋镇、北景乡土地储备耕地项目毕节市大银镇羊桥村杉林皮坡小规模土地开发张掖市民乐县三堡基本农田整理项目东阳市江北街道原冰塘村造田造地项目禹村镇程家峪村基本基本农田整理项目洛川县槐柏镇贝郊村土地复垦项目保靖县清水乡马王村土地整理项目。
excel获得汉字首字母的方法
在日常工作和学习中,我们经常需要对文本进行处理和分析,尤其是对于中文文本。
在处理中文文本时,有时会遇到需要将汉字转换为拼音的需求。
而在Excel中,获得汉字的首字母则成为了一个常见的需求。
那么,如何在Excel中获得汉字的首字母呢?我们可以利用Excel内置的函数来实现这一目标。
在Excel中,可以使用VB脚本编写一个自定义函数来获取汉字的首字母。
具体步骤如下:1. 打开Excel表格,按下ALT + F11,打开VB编辑器。
2. 在VB编辑器中,插入一个新模块。
3. 在新模块中输入以下VB脚本代码:```vbFunction GetFirstLetter(str As String) As StringDim pinyin As StringDim i As IntegerDim ch As Stringpinyin = ""For i = 1 To Len(str)ch = Mid(str, i, 1)pinyin = pinyin &Left(Application.WorksheetFunction.Phonetic(ch), 1)Next iGetFirstLetter = pinyinEnd Function```4. 编译保存后,返回Excel表格界面。
5. 在需要获取汉字首字母的单元格中输入`=GetFirstLetter(A1)`,其中A1为需要转换的汉字所在的单元格。
6. 按下Enter键,即可在目标单元格中获取到相应汉字的首字母。
通过上述方法,我们可以轻松地在Excel中获得汉字的首字母,而且可以将这个函数在多个单元格中批量应用,提高工作效率。
除了使用VB脚本自定义函数外,我们还可以借助Excel内置的函数来实现汉字首字母的获取。
在Excel中,有一个叫做UNICODE的函数,可以返回指定字符的Unicode编码。
而对于汉字来说,其首字母的Unicode编码可以作为其拼音的首字母。
wps表格教程三秒钟获取字词对应的第一个字母
4,1101,1609,1793,2080,2560,2902,3845,4107,4679,5154,53 97,5405,5689,617
0,6229,7001,7481,7763,8472,9264},{"A","B","C","D","E","F", "G","H","J",
"K","L","M","N","O","P","Q","R","S","T","W","X","Y","Z"}) 9,6170,6229,7001,7481,7763,8472,9264},{ "A","B","C","D"
,"E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T"," W","X","
Y","Z"})
5405,5689,6170,6229,7001,7481,7763,8472,9264},{"A","B"," C","D","E","F"
php获取中文字符拼音首字母
php获取中文字符拼音首字母//php获取中文字符拼音首字母function getFirstCharter($str){if(empty($str)){return '';}$fchar=ord($str{0});if($fchar>=ord('A')&&$fchar<=ord('z')) return strtoupper($str{0});$s1=iconv('UTF-8','gb2312',$str);$s2=iconv('gb2312','UTF-8',$s1);$s=$s2==$str?$s1:$str;$asc=ord($s{0})*256+ord($s{1})-65536;if($asc>=-20319&&$asc<=-20284) return 'A';if($asc>=-20283&&$asc<=-19776) return 'B';if($asc>=-19775&&$asc<=-19219) return 'C';if($asc>=-19218&&$asc<=-18711) return 'D';if($asc>=-18710&&$asc<=-18527) return 'E';if($asc>=-18526&&$asc<=-18240) return 'F';if($asc>=-18239&&$asc<=-17923) return 'G';if($asc>=-17922&&$asc<=-17418) return 'H';if($asc>=-17417&&$asc<=-16475) return 'J';if($asc>=-16474&&$asc<=-16213) return 'K';if($asc>=-16212&&$asc<=-15641) return 'L';if($asc>=-15640&&$asc<=-15166) return 'M';if($asc>=-15165&&$asc<=-14923) return 'N';if($asc>=-14922&&$asc<=-14915) return 'O';if($asc>=-14914&&$asc<=-14631) return 'P';if($asc>=-14630&&$asc<=-14150) return 'Q';if($asc>=-14149&&$asc<=-14091) return 'R';if($asc>=-14090&&$asc<=-13319) return 'S';if($asc>=-13318&&$asc<=-12839) return 'T'; if($asc>=-12838&&$asc<=-12557) return 'W'; if($asc>=-12556&&$asc<=-11848) return 'X'; if($asc>=-11847&&$asc<=-11056) return 'Y'; if($asc>=-11055&&$asc<=-10247) return 'Z'; return null;}echo getFirstCharter('张');。
提取汉字首字母函数
提取汉字首字母函数在Python中实现汉字首字母提取函数可以使用拼音库pypinyin,具体操作步骤如下:1. 安装pypinyin库,可以使用pip命令进行安装:```pip install pypinyin```2. 在Python脚本中导入pypinyin库和re库:3. 定义汉字首字母提取函数,其中text为要提取的中文文本,is_acronym为是否需要保留首字母的大写字母:```pythondef chinese_to_acronym(text, is_acronym=True):# 使用pypinyin库将中文转换为拼音pinyin_list = zy_pinyin(text)result = ''# 遍历拼音列表,取每个拼音的首字母for py in pinyin_list:letter = py[0]# 使用正则表达式判断首字母是否为英文字母if re.match('[a-zA-Z]', letter):result += letter.upper() if is_acronym else letter.lower()else:result += letterreturn result```4. 调用汉字首字母提取函数,可以把中文字符串作为参数传递给该函数,得到其首字母字串:```pythontext = '中文处理是一项有趣且需要思考的任务'acronym = chinese_to_acronym(text)print(acronym) # 输出结果为 ZWCLSYXYST```这样就可以实现从中文文本中提取首字母的功能。
函数还可以接收可选参数is_acronym来控制是否需要保留首字母的大写形式。
如果is_acronym为True,则转换后的首字母大写;如果为False,则全部转换为小写字母。
汉字首字母提取在中文信息处理中非常常见,包括中文输入法、联系人姓名排序、音乐流派分类等等。
提取汉字首拼字母
-12860, -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585,
-12556, -12359, -12346,
-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,
-10329, -10328, -10322, -10315, -10309, -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256,
-10254
};
private static string[] pystr = new string[]
"huo", "ji", "jia", "jian",
"jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan",
Java获取中文拼音、中文首字母缩写和中文首字母的示例
Java获取中⽂拼⾳、中⽂⾸字母缩写和中⽂⾸字母的⽰例我们有时候会遇到这样的情况,需要获取某些中⽂的拼⾳、中⽂⾸字母缩写和中⽂⾸字母,下⾯我将为⼤家介绍⼀下如何获取中⽂拼⾳的缩写。
1、项⽬建⽴和配置⾸先,我们建⽴⼀个Java项⽬,新建libs⽂件夹并引⼊⼀个734a7099-4830-39f2-a136-0e850ccdcc7a.jar⽂件,这个步骤相信就不⽤详细写了,跳过。
2、获取中⽂拼⾳(如:⼴东省 -->guangdongsheng)</pre><pre name="code" class="java"><span style="white-space:pre"> </span>/*** 得到中⽂全拼* @param src 需要转化的中⽂字符串* @return*/public static String getPingYin(String src){char[] t1 = null;t1 = src.toCharArray();String[] t2 = new String[t1.length];HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat();t3.setCaseType(HanyuPinyinCaseType.LOWERCASE);t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE);t3.setVCharType(HanyuPinyinVCharType.WITH_V);String t4 = "";int t0 = t1.length;try{for (int i = 0; i < t0; i++){// 判断是否为汉字字符if (ng.Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+")){t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);t4 += t2[0];} else{t4 += ng.Character.toString(t1[i]);}}return t4;} catch (BadHanyuPinyinOutputFormatCombination e1){e1.printStackTrace();}return t4;}3、获取中⽂⾸字母缩写(如:⼴东省-->gds)</pre><pre name="code" class="java"><span style="white-space:pre"> </span>/*** 得到中⽂⾸字母* @param str 需要转化的中⽂字符串* @return*/public static String getPinYinHeadChar(String str){String convert = "";for (int j = 0; j < str.length(); j++){char word = str.charAt(j);String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);if (pinyinArray != null){convert += pinyinArray[0].charAt(0);} else{convert += word;}}return convert;}4、获取中⽂⾸字母并把转化为⼤写字母(如:⼴东省--> G)我们需要结合步骤3 getPinYinHeadChar⽅法,代码如下:</pre><pre name="code" class="java"><span style="white-space:pre"> </span>String s = getPinYinHeadChar("⼴东省"); System.out.println("得到拼⾳⾸字母缩写为:" + s);StringBuffer sb = new StringBuffer(s);if (sb.length() > 1){String ss = sb.delete(1, sb.length()).toString();System.out.println("得到的⾸字母为:"+ Character.toUpperCase(ss.toCharArray()[0]) + "");以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
图解excel中提取中文首字母
汉字中还包含英文字母或数字,英文或数字部分也要返回。
比如:中国航天6号a返回应为:ZGHT6Ha方法:1、打开EXCEL文件,按ALT+F11,弹出代码窗口。
2、点工具栏的:插入——模块。
3、在右面窗口中粘贴下面代码。
4、点保存,关闭并返回EXCEL窗口。
5、若A1内容为中国航天6号a,则在某空白格中输入:=hztopy(A1) 即可复制下面蓝色的代码:Function hztopy(hzpy As String) As StringDim hzstring As String, pystring As StringDim hzpysum As Integer, hzi As Integer, hzpyhex As Integer hzstring = Trim(hzpy)hzpysum = Len(Trim(hzstring))pystring = ""For hzi = 1 To hzpysumhzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))Select Case hzpyhexCase &HB0A1 To &HB0C4: pystring = pystring + "A"Case &HB0C5 To &HB2C0: pystring = pystring + "B"Case &HB2C1 To &HB4ED: pystring = pystring + "C"Case &HB4EE To &HB6E9: pystring = pystring + "D"Case &HB6EA To &HB7A1: pystring = pystring + "E"Case &HB7A2 To &HB8C0: pystring = pystring + "F"Case &HB8C1 To &HB9FD: pystring = pystring + "G"Case &HB9FE To &HBBF6: pystring = pystring + "H"Case &HBBF7 To &HBFA5: pystring = pystring + "J"Case &HBFA6 To &HC0AB: pystring = pystring + "K"Case &HC0AC To &HC2E7: pystring = pystring + "L"Case &HC2E8 To &HC4C2: pystring = pystring + "M"Case &HC4C3 To &HC5B5: pystring = pystring + "N"Case &HC5B6 To &HC5BD: pystring = pystring + "O"Case &HC5BE To &HC6D9: pystring = pystring + "P"Case &HC6DA To &HC8BA: pystring = pystring + "Q"Case &HC8BB To &HC8F5: pystring = pystring + "R"Case &HC8F6 To &HCBF9: pystring = pystring + "S"Case &HCBFA To &HCDD9: pystring = pystring + "T"Case &HEDC5: pystring = pystring + "T"Case &HCDDA To &HCEF3: pystring = pystring + "W"Case &HCEF4 To &HD1B8: pystring = pystring + "X"Case &HD1B9 To &HD4D0: pystring = pystring + "Y"Case &HD4D1 To &HD7F9: pystring = pystring + "Z"Case Elsepystring = pystring + Mid(hzstring, hzi, 1)End SelectNexthztopy = pystringEnd Function。
excel查找函数应用:如何提取姓名的拼音首字母
excel查找函数应用:如何提取姓名的拼音首字母编按:哈喽,大家好!如果此刻让你快速提取汉字拼音的首字母,你会怎么做呢?相信大多数小伙伴面对这个问题时,都会蒙圈,可能会想“这应该得用VBA解决吧,函数应该不行吧。
”其实呀,这个问题用大家都会的VLOOKUP函数就能搞定,赶紧来看看吧!例如A列是员工姓名,需要在B列填写对应的拼音首字母:如果遇上这种问题该怎么办?用户来说,难道真的只能一个一个手动输入吗?实际上使用一个大家都非常熟悉的VLOOKUP函数也是可以搞定这个问题的,不过公式嘛,就有点吓人,是这个样子的:看到这个公式是不是都蒙圈了。
可千万不要被这个表面上看起来很夸张的公式吓到,我们换一种写法,也许你就看明白了。
怎么样,这个公式是不是有点看明白了。
与第一个公式的区别就在于,后面这个公式是把VLOOKUP的第二参数放在单元格区域中了,公式的本质并没有什么区别。
因为名单中的姓名都不超过三个字,所以先用MID函数将每个字单独提取出来,使用VLOOKUP得到每个字的拼音首字母,再把三个VLOOKUP函数用&连接起来。
因此公式的核心其实是=VLOOKUP(MID(A2,1,1),$D$1:$E$24,2)。
对于VLOOKUP函数的用法,大家应该都比较熟悉了,格式是:VLOOKUP(查找值,查找区域,在第几列找,怎么找)。
在本例中,要重点说明的有下面几个要点:1.第一参数可以使用公式,本例中分别使用MID(A2,1,1)、MID(A2,2,1)和MID(A2,3,1)作为查找值;2.本例中的VLOOKUP函数只用了三个参数,同时省略了第三参数2后面的逗号,这种写法表示使用了VLOOKUP函数模糊匹配,与第四参数为1的功能相同;3.关于省略VLOOKUP函数最后一个参数的意义,一定要注意一点,省略参数而不省略逗号时,表示精确匹配,与第四参数为0的功能相同;4.有时候为了避免使用单元格区域作为查找区域,第二参数可以使用常量数组的方式,本例中开头的公式就是用到了常量数组。
excel:汉字拼音首字母提取
方法一:VBA自定义函数"=hztopy()"下面是一个VBA自定义函数,工具->宏->Visual Basic编辑器->,插入模块,在VBA编辑器里面->插入->模块->贴入下述代码,(按ALT+F11,插入模块,在右面窗口中粘贴下面代码)那么,比如在A3中有"进退两难",则在B3中输入"=hztopy(A3)",则会得到"JTLN"。
不过此法有时候也会出错,比如"皓、鑫、婷、雯、奕"等,就无法提取汉字拼音首字母。
Function hztopy(hzpy As String) As StringDim hzstring As String, pystring As StringDim hzpysum As Integer, hzi As Integer, hzpyhex As Integerhzstring = Trim(hzpy)hzpysum = Len(Trim(hzstring))pystring = ""For hzi = 1 To hzpysumhzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))Select Case hzpyhexCase &HB0A1 To &HB0C4: pystring = pystring + "A"Case &HB0C5 To &HB2C0: pystring = pystring + "B"Case &HB2C1 To &HB4ED: pystring = pystring + "C"Case &HB4EE To &HB6E9: pystring = pystring + "D"Case &HB6EA To &HB7A1: pystring = pystring + "E"Case &HB7A2 To &HB8C0: pystring = pystring + "F"Case &HB8C1 To &HB9FD: pystring = pystring + "G"Case &HB9FE To &HBBF6: pystring = pystring + "H"Case &HBBF7 To &HBFA5: pystring = pystring + "J"Case &HBFA6 To &HC0AB: pystring = pystring + "K"Case &HC0AC To &HC2E7: pystring = pystring + "L"Case &HC2E8 To &HC4C2: pystring = pystring + "M"Case &HC4C3 To &HC5B5: pystring = pystring + "N"Case &HC5B6 To &HC5BD: pystring = pystring + "O"Case &HC5BE To &HC6D9: pystring = pystring + "P"Case &HC6DA To &HC8BA: pystring = pystring + "Q"Case &HC8BB To &HC8F5: pystring = pystring + "R"Case &HC8F6 To &HCBF9: pystring = pystring + "S"Case &HCBFA To &HCDD9: pystring = pystring + "T"Case &HEDC5: pystring = pystring + "T"Case &HCDDA To &HCEF3: pystring = pystring + "W"Case &HCEF4 To &HD1B8: pystring = pystring + "X"Case &HD1B9 To &HD4D0: pystring = pystring + "Y"Case &HD4D1 To &HD7F9: pystring = pystring + "Z"Case Elsepystring = pystring + Mid(hzstring, hzi, 1)End SelectNexthztopy = pystringEnd Function方法二:VBA自定义函数"=getpy()"下面是一个VBA自定义函数,工具->宏->Visual Basic编辑器->,插入模块,在VBA编辑器里面->插入->模块->贴入上述代码,那么。
js汉字首字母获取
js汉字⾸字母获取版权声明:知识本就需要传播,如果你需要请⾃⾏转⾛。
1:要求:将指定标签内的汉字字符串转为拼⾳⾸字母拼接字符串;于是将⽹上的代码整理了⼀下;2:原理:从编码库中取出单个汉字的⾸字母再拼接3:引⽤两个变量:(1)(2)var oMultiDiff= {"19969":"DZ","19975":"WM","19988":"QJ","20048":"YL","20056":"SC","20060":"NM","20094":"QG","20127":"QJ","20167":"QC","20193":"YG","20250":"KH","20256":"ZC","20282":"SC","20285":"QJG"," 4:编写⾃⼰的获取页⾯[html]1. <!DOCTYPE html>2. <html>3. <head>4. <meta charset="UTF-8">5. <title>汉字转拼⾳⾸字母</title>6. <script type="text/javascript" src="js/jquery.min.js" ></script>7. <script type="text/javascript" src="js/py.js" ></script>8. <script type="text/javascript">9. //转字符串数组程序10. function makePy(str)11. {12. if(typeof(str) != "string")13. throw new Error(-1,"函数makePy需要字符串类型参数!");14. var arrResult = new Array();15. //将字符串转码后转为数组16. for(var i=0,len=str.length;i<len;i++)17. {18. var ch = str.charAt(i);19. arrResult.push(checkCh(ch));20. }21. return mkRslt(arrResult);22. }23. //测试程序24. function get()25. {26. var str = document.getElementById("text").value;27. alert(makePy(str));28. }29.30.31. function checkCh(ch)32. {33. var uni = ch.charCodeAt(0);34. //如果不在汉字处理范围之内,返回原字符,也可以调⽤⾃⼰的处理函数35. if(uni > 40869 || uni < 19968)36. return ch; //dealWithOthers(ch);37. //检查是否是多⾳字,是按多⾳字处理,不是就直接在strChineseFirstPY字符串中找对应的⾸字母38. return (oMultiDiff[uni]?oMultiDiff[uni]:(strChineseFirstPY.charAt(uni-19968)));39. }40. function mkRslt(arr)41. {42. var arrRslt = [""];43. for(var i=0,len=arr.length;i<len;i++)44. {45. var str = arr[i];46. var strlen = str.length;47. if(strlen == 1)48. {49. for(var k=0;k<arrRslt.length;k++)50. {51. arrRslt[k] += str;52. }53. }54. else55. {56. var tmpArr = arrRslt.slice(0);57. arrRslt = [];58. for(k=0;k<strlen;k++)59. {60. //复制⼀个相同的arrRslt61. var tmp = tmpArr.slice(0);62. //把当前字符str[k]添加到每个元素末尾63. for(var j=0;j<tmp.length;j++)64. {65. tmp[j] += str.charAt(k);66. }67. //把复制并修改后的数组连接到arrRslt上68. arrRslt = arrRslt.concat(tmp);69. }70. }71. }72. return arrRslt;73. }74.75.76. </script>77. </head>78. <body>79. <input type="text" id="text" >80. <input type="button" onclick="javascript:get()" value="查看拼⾳" >81. </body>82. </html>。
使用PHP获取汉字的拼音(全部与首字母)
使⽤PHP获取汉字的拼⾳(全部与⾸字母)废话不多说,直接上代码:复制代码代码如下:<?phpclass GetPingYing {private $pylist = array('a'=>-20319,'ai'=>-20317,'an'=>-20304,'ang'=>-20295,'ao'=>-20292,'ba'=>-20283,'bai'=>-20265,'ban'=>-20257,'bang'=>-20242,'bao'=>-20230,'bei'=>-20051,'ben'=>-20036,'beng'=>-20032,'bi'=>-20026,'bian'=>-20002,'biao'=>-19990,'bie'=>-19986,'bin'=>-19982,'bing'=>-19976,'bo'=>-19805,'bu'=>-19784,'ca'=>-19775,'cai'=>-19774,'can'=>-19763,'cang'=>-19756,'cao'=>-19751,'ce'=>-19746,'ceng'=>-19741,'cha'=>-19739,'chai'=>-19728,'chan'=>-19725,'chang'=>-19715,'chao'=>-19540,'che'=>-19531,'chen'=>-19525,'cheng'=>-19515,'chi'=>-19500,'chong'=>-19484,'chou'=>-19479,'chu'=>-19467,'chuai'=>-19289,'chuan'=>-19288,'chuang'=>-19281,'chui'=>-19275,'chun'=>-19270,'chuo'=>-19263,'ci'=>-19261,'cong'=>-19249,'cou'=>-19243,'dan'=>-19038, 'dang'=>-19023, 'dao'=>-19018, 'de'=>-19006,'deng'=>-19003, 'di'=>-18996,'dian'=>-18977, 'diao'=>-18961, 'die'=>-18952,'ding'=>-18783, 'diu'=>-18774,'dong'=>-18773, 'dou'=>-18763, 'du'=>-18756,'duan'=>-18741, 'dui'=>-18735,'dun'=>-18731, 'duo'=>-18722, 'e'=>-18710,'en'=>-18697,'er'=>-18696,'fa'=>-18526,'fan'=>-18518,'fang'=>-18501, 'fei'=>-18490,'fen'=>-18478,'feng'=>-18463, 'fo'=>-18448,'fou'=>-18447,'fu'=>-18446,'ga'=>-18239,'gai'=>-18237,'gan'=>-18231, 'gang'=>-18220, 'gao'=>-18211, 'ge'=>-18201,'gei'=>-18184,'gen'=>-18183, 'geng'=>-18181, 'gong'=>-18012, 'gou'=>-17997, 'gu'=>-17988,'gua'=>-17970, 'guai'=>-17964, 'guan'=>-17961, 'guang'=>-17950, 'gui'=>-17947,'gun'=>-17931, 'guo'=>-17928, 'ha'=>-17922,'hai'=>-17759,'han'=>-17752, 'hang'=>-17733, 'hao'=>-17730,'huai'=>-17487, 'huan'=>-17482, 'huang'=>-17468, 'hui'=>-17454,'hun'=>-17433, 'huo'=>-17427, 'ji'=>-17417,'jia'=>-17202,'jian'=>-17185, 'jiang'=>-16983, 'jiao'=>-16970, 'jie'=>-16942,'jin'=>-16915,'jing'=>-16733, 'jiong'=>-16708, 'jiu'=>-16706,'ju'=>-16689,'juan'=>-16664, 'jue'=>-16657,'jun'=>-16647,'ka'=>-16474,'kai'=>-16470,'kan'=>-16465, 'kang'=>-16459, 'kao'=>-16452, 'ke'=>-16448,'ken'=>-16433, 'keng'=>-16429, 'kong'=>-16427, 'kou'=>-16423, 'ku'=>-16419,'kua'=>-16412, 'kuai'=>-16407, 'kuan'=>-16403, 'kuang'=>-16401, 'kui'=>-16393,'kun'=>-16220, 'kuo'=>-16216, 'la'=>-16212,'lai'=>-16205,'lan'=>-16202,'lang'=>-16187, 'lao'=>-16180,'le'=>-16171,'lei'=>-16169,'leng'=>-16158, 'li'=>-16155,'lia'=>-15959,'lian'=>-15958, 'liang'=>-15944, 'liao'=>-15933, 'lie'=>-15920,'lin'=>-15915,'ling'=>-15903,'luo'=>-15652, 'ma'=>-15640, 'mai'=>-15631, 'man'=>-15625, 'mang'=>-15454, 'mao'=>-15448, 'me'=>-15436, 'mei'=>-15435, 'men'=>-15419, 'meng'=>-15416, 'mi'=>-15408,'mian'=>-15394, 'miao'=>-15385, 'mie'=>-15377, 'min'=>-15375, 'ming'=>-15369, 'miu'=>-15363, 'mo'=>-15362, 'mou'=>-15183, 'mu'=>-15180, 'na'=>-15165, 'nai'=>-15158, 'nan'=>-15153, 'nang'=>-15150, 'nao'=>-15149, 'ne'=>-15144, 'nei'=>-15143, 'nen'=>-15141, 'neng'=>-15140, 'ni'=>-15139,'nian'=>-15128, 'niang'=>-15121, 'niao'=>-15119, 'nie'=>-15117, 'nin'=>-15110, 'ning'=>-15109, 'niu'=>-14941, 'nong'=>-14937, 'nu'=>-14933, 'nv'=>-14930,'nuan'=>-14929, 'nue'=>-14928, 'nuo'=>-14926, 'o'=>-14922,'ou'=>-14921, 'pa'=>-14914, 'pai'=>-14908, 'pan'=>-14902, 'pang'=>-14894, 'pao'=>-14889, 'pei'=>-14882, 'pen'=>-14873, 'peng'=>-14871, 'pi'=>-14857,'qia'=>-14594,'qian'=>-14429, 'qiang'=>-14407, 'qiao'=>-14399, 'qie'=>-14384,'qin'=>-14379,'qing'=>-14368, 'qiong'=>-14355, 'qiu'=>-14353,'qu'=>-14345,'quan'=>-14170, 'que'=>-14159,'qun'=>-14151,'ran'=>-14149,'rang'=>-14145, 'rao'=>-14140,'re'=>-14137,'ren'=>-14135,'reng'=>-14125, 'ri'=>-14123,'rong'=>-14122, 'rou'=>-14112,'ru'=>-14109,'ruan'=>-14099, 'rui'=>-14097,'run'=>-14094,'ruo'=>-14092,'sa'=>-14090,'sai'=>-14087,'san'=>-14083,'sang'=>-13917, 'sao'=>-13914,'se'=>-13910,'sen'=>-13907,'seng'=>-13906, 'sha'=>-13905,'shai'=>-13896,'shan'=>-13894, 'shang'=>-13878, 'shao'=>-13870, 'she'=>-13859,'shen'=>-13847, 'sheng'=>-13831, 'shi'=>-13658,'shou'=>-13611, 'shu'=>-13601,'shua'=>-13406, 'shuai'=>-13404, 'shuan'=>-13400, 'shuang'=>-13398, 'shui'=>-13395,'shun'=>-13391, 'shuo'=>-13387, 'si'=>-13383,'tai'=>-13147, 'tan'=>-13138, 'tang'=>-13120, 'tao'=>-13107, 'te'=>-13096,'teng'=>-13095, 'ti'=>-13091,'tian'=>-13076, 'tiao'=>-13068, 'tie'=>-13063, 'ting'=>-13060, 'tong'=>-12888, 'tou'=>-12875, 'tu'=>-12871,'tuan'=>-12860, 'tui'=>-12858, 'tun'=>-12852, 'tuo'=>-12849, 'wa'=>-12838, 'wai'=>-12831, 'wan'=>-12829, 'wang'=>-12812, 'wei'=>-12802, 'wen'=>-12607, 'weng'=>-12597, 'wo'=>-12594, 'wu'=>-12585, 'xi'=>-12556,'xia'=>-12359, 'xian'=>-12346, 'xiang'=>-12320, 'xiao'=>-12300, 'xie'=>-12120, 'xin'=>-12099, 'xing'=>-12089, 'xiong'=>-12074, 'xiu'=>-12067, 'xu'=>-12058, 'xuan'=>-12039, 'xue'=>-11867, 'xun'=>-11861, 'ya'=>-11847, 'yan'=>-11831, 'yang'=>-11798, 'yao'=>-11781, 'ye'=>-11604, 'yi'=>-11589,'yin'=>-11536, 'ying'=>-11358, 'yo'=>-11340, 'yong'=>-11339, 'you'=>-11324, 'yu'=>-11303, 'yuan'=>-11097,'zei'=>-11020,'zen'=>-11019,'zeng'=>-11018,'zha'=>-11014,'zhai'=>-10838,'zhan'=>-10832,'zhang'=>-10815,'zhao'=>-10800,'zhe'=>-10790,'zhen'=>-10780,'zheng'=>-10764,'zhi'=>-10587,'zhong'=>-10544,'zhou'=>-10533,'zhu'=>-10519,'zhua'=>-10331,'zhuai'=>-10329,'zhuan'=>-10328,'zhuang'=>-10322,'zhui'=>-10315,'zhun'=>-10309,'zhuo'=>-10307,'zi'=>-10296,'zong'=>-10281,'zou'=>-10274,'zu'=>-10270,'zuan'=>-10262,'zui'=>-10260,'zun'=>-10256,'zuo'=>-10254);//全部拼⾳public function getAllPY($chinese, $delimiter = '', $length = 0) { $py = $this->zh_to_pys($chinese, $delimiter);if($length) {$py = substr($py, 0, $length);}return $py;}//拼⾳⾸个字母public function getFirstPY($chinese){$result = '' ;for ($i=0; $i<strlen($chinese); $i++) {$p = ord(substr($chinese,$i,1));if ($p>160) {$q = ord(substr($chinese,++$i,1));$p = $p*256 + $q - 65536;}$result .= substr($this->zh_to_py($p),0,1);}return $result ;}} elseif ($num<-20319||$num>-10247) {return $blank;} else {foreach ($this->pylist as $py => $code) {if($code > $num) break;$result = $py;}return $result;}}private function zh_to_pys($chinese, $delimiter = ' ', $first=0){$result = array();for($i=0; $i<strlen($chinese); $i++) {$p = ord(substr($chinese,$i,1));if($p>160) {$q = ord(substr($chinese,++$i,1));$p = $p*256 + $q - 65536;}$result[] = $this->zh_to_py($p);if ($first) {return $result[0];}}return implode($delimiter, $result);}}//-------------------------中⽂转拼⾳结束--------------------------------////中⽂是双字节,所以需要两个字节连接起来(ASCII码的范围是在161-255)$c = '齐秦';for($i=0; $i<strlen($c); $i++) {echo ord($c[$i]).' ';//198 235 199 216}echo '<br>',chr(198).chr(235).chr(199).chr(216),'<br>';//测试$PingYing = new GetPingYing();echo '<br>',$PingYing->getFirstPY('⽻泉乐队,歌不错-推荐'),'<br>';//yqldgbc-tjecho $PingYing->getAllPY('⽻泉乐队,歌不错-推荐'),'<br>'; //yuquanleduigebucuo-tuijian >。
EXCEL如何提取汉字首字母
方法/步骤1.首先,打开Excel,同时按下Alt+F11键,打开VBE界面,如下图所示。
在VBE界面中,单击图片中所示的左上角空白处,选择“插入“,”模块“。
2.此时,就插入了一个模块,后面的代码就要放到这个模块中,保证右侧空白区域是模块代码的编辑区(最保险的做法是双击模块),然后执行下一步操作。
3.将下面的代码全部复制粘贴到空白区域。
Function pinyin(p As String) As Stringi = Asc(p)Select Case iCase -20319 To -20284: pinyin = "A"Case -20283 To -19776: pinyin = "B"Case -19775 To -19219: pinyin = "C"Case -19218 To -18711: pinyin = "D"Case -18710 To -18527: pinyin = "E"Case -18526 To -18240: pinyin = "F"Case -18239 To -17923: pinyin = "G"Case -17922 To -17418: pinyin = "H"Case -17417 To -16475: pinyin = "J"Case -16474 To -16213: pinyin = "K"Case -16212 To -15641: pinyin = "L"Case -15640 To -15166: pinyin = "M"Case -15165 To -14923: pinyin = "N"Case -14922 To -14915: pinyin = "O"Case -14914 To -14631: pinyin = "P"Case -14630 To -14150: pinyin = "Q"Case -14149 To -14091: pinyin = "R"Case -14090 To -13319: pinyin = "S"Case -13318 To -12839: pinyin = "T" Case -12838 To -12557: pinyin = "W" Case -12556 To -11848: pinyin = "X" Case -11847 To -11056: pinyin = "Y" Case -11055 To -2050: pinyin = "Z" Case Else: pinyin = pEnd SelectEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy& pinyin(Mid(str, i, 1)) Next iEnd Function4.然后关闭这个新界面,返回Excel,就可以像Excel自带的函数一样使用这个自定义的Getpy函数了,它只有一个参数,参数可以直接指定单元格,也可以直接输入字符。
提取汉字首拼字母
提取汉字首拼字母C#提取汉字拼音首字母的方法今天突然要用到提取汉字拼音首字母的功能,去网上找了找,发现没有几个好用的,决定自己写一个,效果还不错,发出来大家一起研究下,分享给大家!直接入主题:1.首先对编码进行定义#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,-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,-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","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","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",#endregion2.然后就是拼音的处理方法了#region 拼音处理/// <summary>/// 将一串中文转化为拼音/// 如果给定的字符为非中文汉字将不执行转化,直接返回原字符;/// </summary>/// <param name="chsstr">指定汉字</param>/// <returns>拼音码</returns>public string ChsString2Spell(string chsstr){string strRet = string.Empty;char[] ArrChar = chsstr.ToCharArray();foreach (char c in ArrChar){strRet += SingleChs2Spell(c.ToString());}return strRet;}/// <summary>/// 将一串中文转化为拼音/// </summary>/// <param name="chsstr">指定汉字</param>/// <returns>拼音首字母</returns>public string GetHeadOfChs(string chsstr){string strRet = string.Empty;char[] ArrChar = chsstr.ToCharArray();foreach (char c in ArrChar){strRet += GetHeadOfSingleChs(c.ToString());}return strRet;}/// <summary>/// 单个汉字转化为拼音/// </summary>/// <param name="SingleChs">单个汉字</param> /// <returns>拼音</returns>public string SingleChs2Spell(string SingleChs){byte[] array;int iAsc;string strRtn = string.Empty;array = Encoding.Default.GetBytes(SingleChs); try{iAsc = (short)(array[0]) * 256 + (short)(array[1]) - 65536;}catch{iAsc = 1;}if (iAsc > 0 && iAsc < 160)return SingleChs;for (int i = (pyvalue.Length - 1); i >= 0; i--){if (pyvalue[i] <= iAsc){strRtn = pystr[i];break;}}//将首字母转为大写if (strRtn.Length > 1){strRtn = strRtn.Substring(0, 1).ToUpper() + strRtn.Substring(1);}return strRtn;}/// <summary>/// 得到单个汉字拼音的首字母/// </summary>/// <returns> </returns>public string GetHeadOfSingleChs(string SingleChs) {return SingleChs2Spell(SingleChs).Substring(0, 1); }#endregion调用方法相信大家都会了,就不多说了!。
ORACLE函数获取汉字拼音首字母
列表一行汉字WITH A AS(SELECT '获取汉字拼音首字母' W FROM DUAL)SELECT SUBSTR(W, ROWNUM, 1) FROM ACONNECT BY ROWNUM <= (SELECT LENGTH(W) FROM A);返回结果获取汉字拼音首字母用汉字字符集对这个列表进行排序WITH A AS(SELECT '获取汉字拼音首字母' W FROM DUAL)SELECT SUBSTR(W, ROWNUM, 1) FROM ACONNECT BY ROWNUM <= (SELECT LENGTH(W) FROM A)ORDER BY NLSSORT(SUBSTR(W, ROWNUM, 1), 'NLS_SORT=SCHINESE_PINYIN_M');返回结果汉获母拼取首音字字那么根据这个原理,上面输入一个拼音A打头的字"澳",后面输入一个B大头的字"吧",找到每个音节的起止的汉字是哪个WITH A AS(SELECT ROWNUM RN, CHR(ROWNUM) C FROM DUAL CONNECT BY LEVEL <= 65535)SELECT * FROM A WHERE LENGTHB(C) = 2AND RN > 32768AND NLSSORT(C, 'NLS_SORT=SCHINESE_PINYIN_M') > NLSSORT('澳','NLS_SORT=SCHINESE_PINYIN_M')AND NLSSORT(C, 'NLS_SORT=SCHINESE_PINYIN_M') < NLSSORT('吧','NLS_SORT=SCHINESE_PINYIN_M')ORDER BY NLSSORT(C, 'NLS_SORT=SCHINESE_PINYIN_M');根据返回的结果,就能看到,A的结束和B的开始的汉子分别是:“驁”“八”,依次类推可以找到其他的分界点,那么最后的函数就是如下:CREATE OR REPLACE FUNCTION F_TRANS_PINYIN_CAPITAL(P_NAME IN VARCHAR2) RETURN VARCHAR2 ASV_COMPARE VARCHAR2(100);V_RETURN VARCHAR2(4000);FUNCTION F_NLSSORT(P_WORD IN VARCHAR2) RETURN VARCHAR2 ASBEGINRETURN NLSSORT(P_WORD, 'NLS_SORT=SCHINESE_PINYIN_M');END;BEGINFOR I IN 1..LENGTH(P_NAME) LOOPV_COMPARE := F_NLSSORT(SUBSTR(P_NAME, I, 1));IF V_COMPARE >= F_NLSSORT(' 吖') AND V_COMPARE <= F_NLSSORT('驁') THENV_RETURN := V_RETURN || 'a';ELSIF V_COMPARE >= F_NLSSORT('八') AND V_COMPARE <= F_NLSSORT('簿') THENV_RETURN := V_RETURN || 'b';ELSIF V_COMPARE >= F_NLSSORT('嚓') AND V_COMPARE <= F_NLSSORT('錯') THENV_RETURN := V_RETURN || 'c';ELSIF V_COMPARE >= F_NLSSORT('咑') AND V_COMPARE <= F_NLSSORT('鵽') THENV_RETURN := V_RETURN || 'd';ELSIF V_COMPARE >= F_NLSSORT('妸') AND V_COMPARE <= F_NLSSORT('樲') THENV_RETURN := V_RETURN || 'e';ELSIF V_COMPARE >= F_NLSSORT('发') AND V_COMPARE <= F_NLSSORT('猤') THENV_RETURN := V_RETURN || 'f';ELSIF V_COMPARE >= F_NLSSORT('旮') AND V_COMPARE <= F_NLSSORT('腂') THENV_RETURN := V_RETURN || 'g';ELSIF V_COMPARE >= F_NLSSORT('妎') AND V_COMPARE <= F_NLSSORT('夻') THENV_RETURN := V_RETURN || 'h';ELSIF V_COMPARE >= F_NLSSORT('丌') AND V_COMPARE <= F_NLSSORT('攈') THENV_RETURN := V_RETURN || 'j';ELSIF V_COMPARE >= F_NLSSORT('咔') AND V_COMPARE <= F_NLSSORT('穒') THENV_RETURN := V_RETURN || 'k';ELSIF V_COMPARE >= F_NLSSORT('垃') AND V_COMPARE <= F_NLSSORT('擽') THENV_RETURN := V_RETURN || 'l';ELSIF V_COMPARE >= F_NLSSORT('嘸') AND V_COMPARE <= F_NLSSORT('椧') THENV_RETURN := V_RETURN || 'm';ELSIF V_COMPARE >= F_NLSSORT('拏') AND V_COMPARE <= F_NLSSORT('瘧') THENV_RETURN := V_RETURN || 'n';ELSIF V_COMPARE >= F_NLSSORT('筽') AND V_COMPARE <= F_NLSSORT('漚') THENV_RETURN := V_RETURN || 'o';ELSIF V_COMPARE >= F_NLSSORT('妑') AND V_COMPARE <= F_NLSSORT('曝') THENV_RETURN := V_RETURN || 'p';ELSIF V_COMPARE >= F_NLSSORT('七') AND V_COMPARE <= F_NLSSORT('裠') THENV_RETURN := V_RETURN || 'q';ELSIF V_COMPARE >= F_NLSSORT('亽') AND V_COMPARE <= F_NLSSORT('鶸') THENV_RETURN := V_RETURN || 'r';ELSIF V_COMPARE >= F_NLSSORT('仨') AND V_COMPARE <= F_NLSSORT('蜶') THENV_RETURN := V_RETURN || 's';ELSIF V_COMPARE >= F_NLSSORT('侤') AND V_COMPARE <= F_NLSSORT('籜') THENV_RETURN := V_RETURN || 't';ELSIF V_COMPARE >= F_NLSSORT('屲') AND V_COMPARE <= F_NLSSORT('鶩') THENV_RETURN := V_RETURN || 'w';ELSIF V_COMPARE >= F_NLSSORT('夕') AND V_COMPARE <= F_NLSSORT('鑂') THENV_RETURN := V_RETURN || 'x';ELSIF V_COMPARE >= F_NLSSORT('丫') AND V_COMPARE <= F_NLSSORT('韻') THENV_RETURN := V_RETURN || 'y';ELSIF V_COMPARE >= F_NLSSORT('帀') AND V_COMPARE <= F_NLSSORT('咗') THENV_RETURN := V_RETURN || 'z';END IF;END LOOP;RETURN V_RETURN;END;测试一下:SELECT F_TRANS_PINYIN_CAPITAL('罗华') FROM DUAL返回lh使用的时候这样查询:select name from users t1 where ( = ? or F_TRANS_PINYIN_CAPITAL() = ?)如果里面的?参数传递的是“罗华”,就是查询用户名是落花的人,如果传递的是lh的话,查询的就是拼音是lh的人。
wps表格教程:三秒钟获取字词对应的第一个字母
"K","L","M","N","O","P","Q","R","S","T","W","X","Y","Z"}) 三、如果想获取前
两个汉字音序怎么办?用“&”将获取第一、二个汉字音 序的公式合并即可。如果想获取前三个汉字音序就用“&” 将获取第一、二、三个汉字音序的公式合并
。 获取字符串前三个汉字音序的公式: =LOOKUP(CODE(A2),45217+{0,36,544,1101,1609,17
54,5397,5405,5689,6170,6229,7001,7481,7763,8472,9264},{ "A","B","C","D"
,"E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T"," W","X","
Y","Z"})
7,5405,5689,6170,6229,7001,7481,7763,8472,9264},{"A","B ","C","D","E","
excel提取汉字的拼音首字母集锦
excel提取汉字的拼音首字母集锦方法一:(最完美的方法)如果你A列的汉字都在4个字符之内,那就在B列输入此公式:=LOOKUP(MID(A1,1,1),{"","";"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"})&LOOKUP(MID(A1,2,1),{"","";"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"})&LOOKUP(MID(A1,3,1),{"","";"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"})&LOOKUP(MID(A1,4,1),{"","";"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"})公式是长了一点,如果把{}里的数据定义为名称,可以转换更多的首字母具体方法:复制{}里的数据,插入-名称(或者按CTRL+F3),定义名称,如图,定义“拼音”为名称,下面的“引用位置”的“=”号后面粘贴刚才复制的{}里的数据确定。
vbs获得汉字拼音及首字母
vbs获得汉字拼音及首字母'=======================获得汉字拼音Set d = () a,-20319: ai,-20317: an,-20304: ang,-20295: ao,-20292: ba,-20283: bai,-20265: ban,-20257: bang,-20242: bao,-20230: bei,-20051: ben,-20036: beng,-20032: bi,-20026: bian,-20002: biao,-19990: bie,-19986: bin,-19982: bing,-19976: bo,-19805: bu,-19784: ca,-19775: cai,-19774: can,-19763: cang,-19756: cao,-19751: ce,-19746: ceng,-19741: cha,-19739: chai,-19728: chan,-19725: chang,-19715: chao,-19540: che,-19531: chen,-19525: cheng,-19515: chi,-19500: chong,-19484: chou,-19479: chu,-19467: chuai,-19289: chuan,-19288: chuang,-19281: chui,-19275: chun,-19270: chuo,-19263: ci,-19261: cong,-19249: cou,-19243: cu,-19242: cuan,-19238: cui,-19235: cun,-19227: cuo,-19224: da,-19218: dai,-19212: dan,-19038: dang,-19023: dao,-19018: de,-19006: deng,-19003: di,-18996: dian,-18977: diao,-18961: die,-18952: ding,-18783: diu,-18774: dong,-18773: dou,-18763: du,-18756: duan,-18741: dui,-18735: dun,-18731: duo,-18722: e,-18710: en,-18697: er,-18696: fa,-18526:fan,-18518: fang,-18501: fei,-18490: fen,-18478: feng,-18463: fo,-18448: fou,-18447: fu,-18446: ga,-18239: gai,-18237: gan,-18231: gang,-18220: gao,-18211: ge,-18201: gei,-18184: gen,-18183: geng,-18181: gong,-18012: gou,-17997: gu,-17988: gua,-17970:,-17964: guan,-17961: guang,-17950: gui,-17947: gun,-17931: guo,-17928: ha,-17922: hai,-17759: han,-17752: hang,-17733: hao,-17730: he,-17721: hei,-17703: hen,-17701: heng,-17697: hong,-17692: hou,-17683: hu,-17676: hua,-17496: huai,-17487: huan,-17482: huang,-17468: hui,-17454: hun,-17433: huo,-17427: ji,-17417: jia,-17202: jian,-17185: jiang,-16983: jiao,-16970: jie,-16942: jin,-16915: jing,-16733: jiong,-16708: jiu,-16706: ju,-16689: juan,-16664: jue,-16657: jun,-16647: ka,-16474: kai,-16470: kan,-16465: kang,-16459: kao,-16452: ke,-16448: ken,-16433: keng,-16429: kong,-16427: kou,-16423: ku,-16419: kua,-16412: kuai,-16407: kuan,-16403: kuang,-16401: kui,-16393: kun,-16220: kuo,-16216: la,-16212: lai,-16205: lan,-16202: lang,-16187: lao,-16180: le,-16171: lei,-16169: leng,-16158: li,-16155: lia,-15959:lian,-15958: liang,-15944: liao,-15933: lie,-15920: lin,-15915: ling,-15903: liu,-15889: long,-15878: lou,-15707: lu,-15701: lv,-15681: luan,-15667: lue,-15661: lun,-15659: luo,-15652: ma,-15640: mai,-15631: man,-15625: mang,-15454: mao,-15448: me,-15436: mei,-15435: men,-15419: meng,-15416: mi,-15408: mian,-15394: miao,-15385: mie,-15377: min,-15375: ming,-15369: miu,-15363: mo,-15362: mou,-15183: mu,-15180: na,-15165: nai,-15158: nan,-15153: nang,-15150: nao,-15149: ne,-15144: nei,-15143: nen,-15141: neng,-15140: ni,-15139: nian,-15128: niang,-15121: niao,-15119: nie,-15117: nin,-15110: ning,-15109: niu,-14941: nong,-14937: nu,-14933: nv,-14930: nuan,-14929: nue,-14928: nuo,-14926: o,-14922: ou,-14921: pa,-14914: pai,-14908: pan,-14902: pang,-14894: pao,-14889: pei,-14882: pen,-14873: peng,-14871: pi,-14857: pian,-14678: piao,-14674: pie,-14670: pin,-14668: ping,-14663: po,-14654: pu,-14645: qi,-14630: qia,-14594: qian,-14429: qiang,-14407: qiao,-14399: qie,-14384: qin,-14379: qing,-14368: qiong,-14355: qiu,-14353: qu,-14345: quan,-14170: que,-14159:qun,-14151: ran,-14149: rang,-14145: rao,-14140: re,-14137: ren,-14135: reng,-14125: ri,-14123: rong,-14122: rou,-14112: ru,-14109: ruan,-14099: rui,-14097: run,-14094: ruo,-14092: sa,-14090: sai,-14087: san,-14083: sang,-13917: sao,-13914: se,-13910: sen,-13907: seng,-13906: sha,-13905: shai,-13896: shan,-13894: shang,-13878: shao,-13870: she,-13859: shen,-13847: sheng,-13831: shi,-13658: shou,-13611: shu,-13601: shua,-13406: shuai,-13404: shuan,-13400: shuang,-13398: shui,-13395: shun,-13391: shuo,-13387: si,-13383: song,-13367: sou,-13359: su,-13356: suan,-13343: sui,-13340: sun,-13329: suo,-13326: ta,-13318:,-13147: tan,-13138: tang,-13120: tao,-13107: te,-13096: teng,-13095: ti,-13091: tian,-13076: tiao,-13068: tie,-13063: ting,-13060: tong,-12888: tou,-12875: tu,-12871: tuan,-12860: tui,-12858: tun,-12852: tuo,-12849: wa,-12838: wai,-12831: wan,-12829: wang,-12812: wei,-12802: wen,-12607: weng,-12597: wo,-12594: wu,-12585: xi,-12556: xia,-12359: xian,-12346: xiang,-12320: xiao,-12300: xie,-12120: xin,-12099: xing,-12089: xiong,-12074: xiu,-12067: xu,-12058:xuan,-12039: xue,-11867: xun,-11861: ya,-11847: yan,-11831: yang,-11798: yao,-11781: ye,-11604: yi,-11589: yin,-11536: ying,-11358: yo,-11340: yong,-11339: you,-11324: yu,-11303: yuan,-11097: yue,-11077: yun,-11067: za,-11055: zai,-11052: zan,-11045: zang,-11041: zao,-11038: ze,-11024: zei,-11020: zen,-11019: zeng,-11018: zha,-11014: zhai,-10838: zhan,-10832: zhang,-10815: zhao,-10800: zhe,-10790: zhen,-10780: zheng,-10764: zhi,-10587: zhong,-10544: zhou,-10533: zhu,-10519: zhua,-10331: zhuai,-10329: zhuan,-10328: zhuang,-10322: zhui,-10315: zhun,-10309: zhuo,-10307: zi,-10296: zong,-10281: zou,-10274: zu,-10270: zuan,-10262: zui,-10260: zun,-10256: zuo,-10254Function g(num) Dim a, i Dim b If num 0 And num 160 Then g = Chr(num) Else If num -20319 Or num -10247 Then g = Else a = b = For i = - 1 To 0 Step -1 If a(i) = num Then Exit For Next g = b(i) End If End If End FunctionFunction c(str) Dim i c = For i = 1 To Len(str) c = c g(Asc(Mid(str, i, 1))) Next End Function'=======================获得汉字首字母PublicFunction getPYChar(char)Dim lChalChar = 65536 + Asc(char)If (lChar = 45217 And lChar = 45252) Then getPYChar = AIf (lChar = 45253 And lChar = 45760) Then getPYChar = BIf (lChar = 47761 And lChar = 46317) Then getPYChar = CIf (lChar = 46318 And lChar = 46825) Then getPYChar = DIf (lChar = 46826 And lChar = 47009) Then getPYChar = EIf (lChar = 47010 And lChar = 47296) Then getPYChar = FIf (lChar = 47297 And lChar = 47613) Then getPYChar = GIf (lChar = 47614 And lChar = 48118) Then getPYChar = HIf (lChar = 48119 And lChar = 49061) Then getPYChar = JIf (lChar = 49062 And lChar = 49323) Then getPYChar = KIf (lChar = 49324 And lChar = 49895) Then getPYChar = LIf (lChar = 49896 And lChar = 50370) Then getPYChar = MIf (lChar = 50371 And lChar = 50613) Then getPYChar = NIf (lChar = 50614 And lChar = 50621) Then getPYChar = OIf (lChar = 50622 And lChar = 50905) Then getPYChar = PIf (lChar = 50906 And lChar = 51386) Then getPYChar = QIf (lChar = 51387 And lChar = 51445) Then getPYChar = RIf (lChar = 51446 And lChar = 52217) Then getPYChar = SIf (lChar = 52218 And lChar = 52697) Then getPYChar = TIf (lChar = 52698 And lChar = 52979) Then getPYChar = WIf (lChar = 52980 And lChar = 53640) ThengetPYChar = XIf (lChar = 53689 And lChar = 54480) Then getPYChar = YIf (lChar = 54481 And lChar = 52289) Then getPYChar = ZEnd FunctionPublic Function getPY(str)For i = 0 To Len(str) - 1 getPY = getPY getPYChar(Mid(str, i + 1, 1))NextEnd Function'=======================获得汉字首字母(getPY(汗))'=======================获得汉字拼音(c(汗))。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
获取汉字的首字母
此文章从网上摘抄留着自己使用,现分享给大家。
我在做一个搜索功能输入首字母显示对应的汉字信息。
在后台录入数据时不能总是让客户把汉字的首字母给输进去。
为了给客户以个好的体现,从后台自动获取汉字首字母存入数据中,当查询的时候方面使用。
public class chInitial {
// 简体中文的编码范围从B0A1(45217)一直到F7FE(63486)
private static int BEGIN = 45217;
private static int END = 63486;
// 按照声母表示,这个表是在GB2312中的出现的第一个汉字,也就是说“啊”是代表首字母a的第一个汉字。
// i, u, v都不做声母, 自定规则跟随前面的字母
private static char[] chartable = { '啊', '芭', '擦', '搭', '蛾', '发', '噶', '哈', '哈', '击', '喀', '垃', '妈', '拿', '哦', '啪', '期', '然', '撒', '塌', '塌',
'塌', '挖', '昔', '压', '匝', };
// 二十六个字母区间对应二十七个端点
// GB2312码汉字区间十进制表示
private static int[] table = new int[27];
// 对应首字母区间表
private static char[] initialtable = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
't', 't', 'w', 'x', 'y', 'z', };
// 初始化
static {
for (int i = 0; i < 26; i++) {
table[i] = gbValue(chartable[i]);// 得到GB2312码的首字母区间端点表,十进制。
}
table[26] = END;// 区间表结尾
}
// ------------------------public方法区------------------------
/**
*根据一个包含汉字的字符串返回一个汉字拼音首字母的字符串最重要的一个方法,思路如下:一个个字符读入、判断、输出
*/
public static String cn2py(String SourceStr) {
String Result = "";
int StrLength = SourceStr.length();
int i;
try {
for (i = 0; i < StrLength; i++) {
Result += Char2Initial(SourceStr.charAt(i));
}
} catch (Exception e) {
Result = "";
}
return Result;
}
/**
*输入字符,得到他的声母,英文字母返回对应的大写字母,其他非简体汉字返回'0' *
*/
private static char Char2Initial(char ch) {
// 对英文字母的处理:小写字母转换为大写,大写的直接返回
if (ch >= 'a' && ch <= 'z')
return (char) (ch - 'a' + 'A');
if (ch >= 'A' && ch <= 'Z')
return ch;
// 对非英文字母的处理:转化为首字母,然后判断是否在码表范围内,
// 若不是,则直接返回。
// 若是,则在码表内的进行判断。
int gb = gbValue(ch);// 汉字转换首字母
if ((gb < BEGIN) || (gb > END))// 在码表区间之前,直接返回
return ch;
int i;
for (i = 0; i < 26; i++) {// 判断匹配码表区间,匹配到就break,判断区间形如“[,)”
if ((gb >= table[i]) && (gb < table[i+1]))
break;
}
if (gb==END) {//补上GB2312区间最右端
i=25;
}
return initialtable[i]; // 在码表区间中,返回首字母
}
/**
*取出汉字的编码cn汉字
*/
private static int gbValue(char ch) {// 将一个汉字(GB2312)转换为十进制表示。
String str = new String();
str += ch;
try {
byte[] bytes = str.getBytes("GB2312");
if (bytes.length < 2)
return 0;
return (bytes[0] << 8 & 0xff00) + (bytes[1] & 0xff);
} catch (Exception e) {
return 0;
}
}
public static void main(String[] args) throws Exception { System.out.println(cn2py("小小鸟"));
}
}。