Java中获取GBK编码汉字的拼音首字母
网上关于Java中获取汉字的拼音首字母的方法很多,但大多基于GB2312的汉字所属编码位置判断方法,现有一种基于GBK编码计算拼音首字母的方法,参考http://blog.csdn.net/z3h/article/details/6302890
笔者出的源码是读取文件默认编码格式,默认是GBK,如果文件默认格式不是GBK将报错,现在代码读取的格式默认设置为GBK,如下:
package com; import java.io.UnsupportedEncodingException; /** * 取得汉字拼音码. * 支持GBK大字符集. * @author Zhao Honghui * @version 1.0 */ public class GetPy { private static final String GB_2312 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbp" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbpbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "pbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccczcccccccccccccc" + "ccccccccccccccccccccccccccccccccccccsccccccccccccc" + "cccccccccccccccccccccccccccccccccccccccccczccccccc" + "cccccccccccccccccccccccccccccccccccccccccccccccccc" + "cccddddddddddddddddddddddddddddddddddddddddddddddd" + "dddddddddddddddddddddzdddddddddddddddddddddddddddd" + "dddddddddddddddddddddddddddddddtdddddddddddddddddd" + "dddddddddddddddddddddddddddddddddddddeeeeeeeeeeeee" + "eeeeeeeeefffffffffffffffffffffffffffffffffffffffff" + "ffffffffffffffffffffffffffffffffffffffffffffffffff" + "fffffffffffffpffffffffffffffffffffgggggggggggggggg" + "ggggggggggggggggggghggggggggggggghgggggggggggggggg" + "gggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggghhhhhhhhhhh" + "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhmhhhhhhhhhhh" + "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" + "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" + "hhhhhhhhhhhhhhhhhhhhjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjkjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjyjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjjkkkgkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkh" + "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" + "kkkkkkkkkkkkkkklllllllllllllllllllllllllllllllllll" + "llllllllllllllllllllllllllllllllllllllllllllllllll" + "llllllllllllllllllllllllllllllllllllllllllllllllll" + "llllllllllllllllllllllllllllllllllllllllllllllllll" + "llllllllllllllllllllllllllllllllllllllllllllllllll" + "lllllllllllllmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm" + "mmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" + "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnooooo" + "oooppppppppppppppppppppppppppppppppppppppppppppppp" + "pppppppppppppppppppppppppppppppppppppppppppppppppp" + "ppppppppppppppppppppppppbqqqqqqqqqqqqqqqqqqqqqqqqq" + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq" + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq" + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrr" + "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrsssssssss" + "ssssssssssssssssssssssssssssssssssssssssssssssssss" + "ssssssssssssssssssssssssssssssssssssssssssssssssss" + "ssssssssssssssssssssssssssssssssssssssssssssssssss" + "ssssssssssssssssssssssssssssssssssssssssssssssssss" + "sssssssssssssssssssssssssssssssssssssssssssssssssx" + "sssssssssssssssssssssssssssttttttttttttttttttttttt" + "tttttttttttttttttttttttttttttttttttttttttttttttttt" + "tttttttttttttttttttttttttttttttttttttttttttttttttt" + "tttttttttttttttttttttttttttttttttwwwwwwwwwwwwwwwww" + "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" + "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" + "wwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxjxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyxyyyyyyyyyyyyyyyyyyyyyyyyy" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzczzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + "zzzzz cjwgnspgcgnesypbtyyzdxykygtdjnnjqmbsjzsc" + "yjsyyfpgkbzgylywjkgkljywkpjqhytwddzlsymrypywwcckzn" + "kyygttngjnykkzytcjnmcylqlypysfqrpzslwbtgkjfyxjwzlt" + "bncxjjjjtxdttsqzycdxxhgckbphffsswybgmxlpbylllhlxst" + "zmyjhsojnghdzqyklgjhsgqzhxqgkxzzwyscscjxyeyxadzpmd" + "ssmzjzqjyzcdjzwqjbyzbjgznzcpwhwxhqkmwfbpbydtjzzkxx" + "ylygxfptyjyyzpszlfchmqshgmxxsxjyqdcsbbqbefsjyhxwgz" + "kpylqbgldlcdtnmaeddkssngycsgxlyzaypnptsdkdylhgymyl" + "cxpycjndqjwxqxfyyfjlejpzrxccqwqqsbzkymgplbmjrqcfln" + "ymyqmtqyrbcjthztqfrxqhxmqjcjlyxgjmshzkbswyemyltxfs" + "ydsglycjqxsjnqbsctyhbftdcyjdjyyghqfsxwckqkxebptlpx" + "jzsrmebwhjlpjslyysmdxlclqkxlhxjrzjmfqhxhwywsbhtrxx" + "glhqhfnmgykldyxzpylggtmtcfpnjjzyljtyanjgbjplqgszyq" + "yaxbkysecjsznslyzhzxlzcghpxzhznytdsbcjkdlzayfmytle" + "bbgqyzkggldndnyskjshdlyxbcgyxypkdjmmzngmmclgezszxz" + "jfznmlzzthcsydbdllscddnlkjykjsycjlkwhqasdknhcsgaeh" + "daashtcplcpqybsdmpjlpzjoqlcdhjxysprchnwjnlhlyyqyhw" + "zptczgwwmzffjqqqqyxaclbhkdjxdgmmydqxzllsygxgkjrywz" + "wyclzmssjzldbydcpcxyhlxchyzjqsfqagmnyxpfrkssbjlyxy" + "syglnscmhcwwmnzjjlxxhchsyzsttxrycyxbyhcsmxjsznpwgp" + "xxtaybgajcxlysdccwzocwkccsbnhcpdyznfcyytyckxkybsqk" + "kytqqxfcwchcykelzqbsqyjqcclmthsywhmktlkjlycxwheqqh" + "tqkjpqsqscfymmdmgbwhwlgsllystlmlxpthmjhwljzyhzjxht" + "xjlhxrswlwzjcbxmhzqxsdzpsgfcsglsxymqshxpjxwmyqksmy" + "plrthbxftpmhyxlchlhlzylxgsssstclsldclrpbhzhxyyfhbb" + "gdmycnqqwlqhjjzywjzyejjdhpblqxtqkwhlchqxagtlxljxms" + "ljhtzkzjecxjcjnmfbycsfywybjzgnysdzsqyrsljpclpwxsdw" + "ejbjcbcnaytwgmpapclyqpclzxsbnmsggfnzjjbzsfzyndxhpl" + "qkzczwalsbccjxjyzgwkypsgxfzfcdkhjgxtlqfsgdslqwzkxt" + "mhsbgzmjzrglyjbpmlmsxlzjqzhzyjczydjwfmjklddpmjegxy" + "hylxhlqyqhkycwcjmyyxnatjhyccxzpcqlbzwwytwsqcmlpmyr" + "jcccxfpznzzljplxxyztzlgdltcklyrzzgqtkjhhgjljaxfgfj" + "zslcfdqzlclgjdjcsnzlljpjqdcclcjxmyzftsxgcgsbrzxjqq" + "ctzhgyqtjqqlzxjylylncyamcstylpdjbyregklzyzhlyszqlz" + "nwczcllwjqjjjkdgjzolbbzppglghtgzxyjhzmycnqsycyhbhg" + "xkamtxyxnbskyzzgjzlqjtfcjxdygjqjjpmgwgjjjpkqsbgbmm" + "cjssclpqpdxcdyykyfcjddyygywrhjrtgznyqldkljszzgzqzj" + "gdykshpzmtlcpwnjyfyzdjcnmwescyglbtzcgmssllyxqsxxbs" + "jsbbsgghfjlypmzjnlyywdqshzxtyywhmcyhywdbxbtlmsyyyf" + "sxjchtxxlhjhfssxzqhfzmzcztqcxzxrttdjhnnyzqqmtqdmmz" + " ytxmjgdxcdyzbffallztdltfxmxqzdngwqdbdczjdxbzgsqqd" + "djcmbkzffxmkdmdsyyszcmljdsynsprskmkmpcklgdbqtfzswt" + "fgglyplljzhgjjgypzltcsmcnbtjbqfkdhpyzgkpbbymtdssxt" + "bnpdkleycjnyddykzddhqhsdzsctarlltkzlgecllkjlqjaqnb" + "dkkghpjxzqksecshalqfmmgjnlyjbbtmlyzxdxjpldlpcqdhzy" + "cbzsczbzmsljflkrzjsnfrgjhxpdhyjybzgdlqcsezgxlblhyx" + "twmabchecmwyjyzlljjyhlgbdjlslygkdzpzxjyyzlwcxszfgw" + "yydlyhcljscmbjhblyzlycblydpdqysxqzbytdkyxlyycnrjmp" + "dqgklcljbcxbjddbblblczqrppxjcjlzcshltoljnmdddlngka" + "thqhjhykheznmshrphqqjchgmfprxhjgdychgklyrzqlcyqjnz" + "sqtkqjymszxwlcfqqqxyfggyptqwlmcrnfkkfsyylybmqammmy" + "xctpshcptxxzzsmphpshmclmldqfyqxszyjdjjzzhqpdszglst" + "jbckbxyqzjsgpsxqzqzrqtbdkwxzkhhgflbcsmdldgdzdblzyy" + "cxnncsybzbfglzzxswmsccmqnjqsbdqsjtxxmbltxcclzshzcx" + "rqjgjylxzfjphymzqqydfqjqlzznzjcdgzygztxmzysctlkpht" + "xhtlbjxjlxscdqxcbbtjfqzfsltjbtkqbxxjjljchczdbzjdcz" + "jdcprnpqcjpfczlclzxzdmxmphjsgzgszzqlylwtjpfsyaxmcj" + "btzyycwmytzsjjlqcqlwzmalbxyfbpnlsfhtgjwejjxxglljst" + "gshjqlzfkcgnndszfdeqfhbsaqtgylbxmmygszldydqmjjrgbj" + "tkgdhgkblqkbdmbylxwcxyttybkmrtjzxqjbhlmhmjjzmqasld" + "cyxyqdlqcafywyxqhz"; private static final String GBK_3 = "ksxsm sdqlybjjjgczbjfya jhphsyzgj sn xy ng" + " lggllyjds yssgyqyd xjyydldwjjwbbftbxthhbczcrfm" + "qwyfcwdzpyddwyxjajpsfnzyjxxxcxnnxxzzbpysyzhmzbqbzc" + "ycbxqsbhhxgfmbhhgqcxsthlygymxalelccxzrcsd njjtzzcl" + "jdtstbnxtyxsgkwyflhjqspxmxxdc lshxjbcfybyxhczbjyzl" + "wlcz gtsmtzxpqglsjfzzlslhdzbwjncjysnycqrzcwybtyftw" + "ecskdcbxhyzqyyxzcffzmjyxxsdcztbzjwszsxyrnygmdthjxs" + "qqccsbxrytsyfbjzgclyzzbszyzqscjhzqydxlbpjllmqxtydz" + "sqjtzplcgqtzwjbhcjdyfxjelbgxxmyjjqfzasyjnsydk jcjs" + "zcbatdclnjqmwnqncllkbybzzsyhjqltwlccxthllzntylnzxd" + "dtcenjyskkfksdkghwnlsjt jymrymzjgjmzgxykymsmjklfxm" + "tghpfmqjsmtgjqdgyalcmzcsdjlxdffjc f ffkgpkhrcjqcj" + "dwjlfqdmlzbjjscgckdejcjdlzyckscclfcq czgpdqzjj hdd" + "wgsjdkccctllpskghzzljlgjgjjtjjjzczmlzyjkxzyzmljkyw" + "xmkjlkjgmclykjqlblkmdxwyxysllpsjqjqxyqfjtjdmxxllcr" + "qyjb xgg pjygegdjgnjyjkhqfqzkhyghdgllsdjjxkyoxnzsx" + "wwxdcskxxjyqscsqkjexsyzhydz ptqyzmtstzfsyldqagylcq" + "lyyyhlrq ldhsssadsjbrszxsjyrcgqc hmmxzdyohycqgphhy" + "nxrhgjlgwqwjhcstwasjpmmrdsztxyqpzxyhyqxtpbfyhhdwzb" + "txhqeexzxxkstexgltxydn hyktmzhxlplbmlsfhyyggbhyqt" + "xwlqczydqdq gd lls zwjqwqajnytlxanzdecxzwwsgqqdyzt" + "chyqzlxygzglydqtjtadyzzcwyzymhyhyjzwsxhzylyskqysbc" + "yw xjzgtyxqsyhxmchrwjpwxzlwjs sgnqbalzzmtjcjktsax" + "ljhhgoxzcpdmhgtysjxhmrlxjkxhmqxctxwzbkhzccdytxqhlx" + "hyx syydz znhxqyaygypdhdd pyzndltwxydpzjjcxmtlhbyn" + "yymhzllhnmylllmdcppxmxdkycydltxchhznaclcclylzsxzjn" + "zln lhyntkyjpychegttgqrgtgyhhlgcwyqkpyyyttttlhylly" + "ttplkyzqqzdq nmjzxyqmktfbjdjjdxbtqzgtsyflqgxblzfh" + " zadpmjhlccyhdzfgydgcyxs hd d axxbpbyyaxcqffqyjxdl" + "jjzl bjydyqszwjlzkcdtctbkdyzdqjnkknjgyeglfykasntch" + "blwzbymjnygzyheyfjmctyfzjjhgck lxhdwxxjkyykssmwctq" + "zlpbzdtwzxzag kwxl lspbclloqmmzslbczzkdcz xgqqdcyt" + "zqwzqssfpktfqdcdshdtdwfhtdy jaqqkybdjyxtlj drqxxxa" + "ydrjlklytwhllrllcxylbw z zzhkhxksmdsyyjpzbsqlcxxn" + "xwmdq gqmmczjgttybhyjbetpjxdqhkzbhfdxkawtwajldyjsf" + "hblddqjncxfjhdfjjwzpkzypcyzynxff ydbzznytxzembsehx" + "fzmbflzrsymzjrdjgxhjgjjnzzxhgxhymlpeyyxtgqshxssxmf" + "mkcctxnypszhzptxwywxyysljsqxzdleelmcpjclxsqhfwwtff" + "tnqjjjdxhwlyznflnkyyjldx hdynrjtywtrmdrqhwqcmfjdyz" + "hmyyxjwzqtxtlmrspwwchjb xygcyyrrlmpymkszyjrmysntpl" + "nbpyyxmykyngjzznlzhhanmpgwjdzmxxmllhgdzxyhxkrycjmf" + "fxyhjfssqlxxndyca nmtcjcyprrnytyqym sxndlylyljnlxy" + "shqmllyzljzxstyzsmcqynzlxbnnylrqtryyjzzhsytxcqgxzs" + "shmkczyqhzjnbh qsnjnzybknlqhznswxkhjyybqlbfl p bkq" + "zxsddjmessmlxxkwnmwwwydkzggtggxbjtdszxnxwmlptfxlcx" + "jjljzxnwxlyhhlrwhsc ybyawjjcwqqjzzyjgxpltzftpakqpt" + "lc xtx hklefdleegqymsawhmljtwyqlyjeybqfnlyxrdsctg" + "gxyyn kyqctlhjlmkkcgygllldzydhzwpjzkdyzzhyyfqytyzs" + "ezzlymhjhtwyzlkyywzcskqqtdxwctyjklwqbdqyncs szjlkc" + "dcdtlzzacqqzzddxyplxzbqjylzllqdzqgyjyjsyxnyyynyjxk" + "xdazwrdljyyynjlxllhxjcykynqcclddnyyykyhhjcl pb qzz" + "yjxj fzdnfpzhddwfmyypqjrssqzsqdgpzjwdsjdhzxwybp gp" + "tmjthzsbgzmbjczwbbzmqcfmbdmcjxljbgjtz mqdyxjzyctyz" + "tzxtgkmybbcljssqymscx jeglxszbqjjlyxlyctsxmcwfa kb" + "qllljyxtyltxdphnhfqyzyes sdhwdjbsztfd czyqsyjdzjqp" + "bs j fbkjbxtkqhmkwjjlhhyyyyywyycdypczyjzwdlfwxwzzj" + "cxcdjzczlxjjtxbfwpxzptdzbccyhmlxbqlrtgrhqtlf mwwjx" + "jwcysctzqhxwxkjybmpkbnzhqcdtyfxbyxcbhxpsxt m sxlhk" + "mzxydhwxxshqhcyxglcsqypdh my ypyyykzljqtbqxmyhcwll" + "cyl ewcdcmlggqktlxkgndgzyjjlyhqdtnchxwszjydnytcqcb" + "hztbxwgwbxhmyqsycmqkaqyncs qhysqyshjgjcnxkzycxsbxx" + "hyylstyxtymgcpmgcccccmztasgqzjlosqylstmqsqdzljqqyp" + "lcycztcqqpbqjclpkhz yyxxdtddsjcxffllxmlwcjcxtspyxn" + "dtjsjwxqqjskyylsjhaykxcyydmamdqmlmczncybzkkyflmcsc" + "lhxrcjjgslnmtjzzygjddzjzk qgjyyxzxxqhheytmdsyyyqlf" + " zzdywhscyqwdrxqjyazzzdywbjwhyqszywnp azjbznbyzzy" + "hnscpjmqcy zpnqtbzjkqqhngccxchbzkddnzhjdrlzlsjljyx" + "ytbgtcsqmnjpjsrxcfjqhtpzsyjwbzzzlstbwwqsmmfdwjyzct" + "bwzwqcslqgdhqsqlyzlgyxydcbtzkpj gm pnjkyjynhpwsnsz" + "zxybyhyzjqjtllcjthgdxxqcbywbwzggqrqzssnpkydznxqxjm" + "y dstzplthzwxwqtzenqzw ksscsjccgptcslccgllzxczqthn" + "jgyqznmckcstjskbjygqjpldxrgzyxcxhgdnlzwjjctsbcjxbf" + "zzpqdhjtywjynlzzpcjdsqjkdxyajyemmjtdljyryynhjbngzj" + "kmjxltbsllrzylcscnxjllhyllqqqlxymswcxsljmc zlnsdwt" + "jllggjxkyhbpdkmmscsgxjcsdybxdndqykjjtxdygmzzdzslo " + "yjsjzdlbtxxxqqjzlbylwsjjyjtdzqqzzzzjlzcdzjhpl qplf" + "fjzysj zfpfzksyjjhxttdxcysmmzcwbbjshfjxfqhyzfsjybx" + "pzlhmbxhzxfywdab lktshxkxjjzthgxh jxkzxszzwhwtzzzs" + "nxqzyawlcwxfxyyhxmyyswqmnlycyspjkhwcqhyljmzxhmcnzh" + "hxcltjplxyjhdyylttxfszhyxxsjbjyayrmlckd yhlrlllsty" + "zyyhscszqxkyqfpflk ntljmmtqyzwtlll s rbdmlqjbcc qy" + "wxfzrzdmcyggzjm mxyfdxc shxncsyjjmpafyfnhyzxyezy " + "sdl zztxgfmyyysnbdnlhpfzdcyfssssn zzdgpafbdbzszbsg" + "cyjlm z yxqcyxzlckbrbrbzcycjzeeyfgzlyzsfrtkqsxdcm" + "z jl xscbykjbbrxllfqwjhyqylpzdxczybdhzrbjhwnjtjxl" + "kcfssdqyjkzcwjl b tzlltlqblcqqccdfpphczlyygjdgwcf" + "czqyyyqyrqzslszfcqnwlhjcjjczkypzzbpdc jgx gdz f" + "gpsysdfwwjzjyxyyjyhwpbygxrylybhkjksftzmmkhtyysyyzp" + "yqydywmtjjrhl tw bjycfnmgjtysyzmsjyjhhqmyrszwtr" + "tzsskx gqgsptgcznjjcxmxgzt ydjz lsdglhyqgggthszpyj" + "hhgnygkggmdzylczlxqstgzslllmlcskbljzzsmmytpzsqjcj " + " zxzzcpshkzsxcdfmwrllqxrfzlysdctmxjthjntnrtzfqyhqg" + "llg sjdjj tqjlnyhszxcgjzypfhdjspcczhjjjzjqdyb ss" + "lyttmqtbhjqnnygjyrqyqmzgcjkpd gmyzhqllsllclmholzgd" + "yyfzsljc zlylzqjeshnylljxgjxlyjyyyxnbzljsszcqqzjyl" + "lzldj llzllbnyl hxxccqkyjxxxklkseccqkkkcgyyxywtqoh" + "thxpyxx hcyeychbbjqcs szs lzylgezwmysx jqqsqyyycmd" + "zywctjsycjkcddjlbdjjzqysqqxxhqjohdyxgmajpchcpljsmt" + "xerxjqd pjdbsmsstktssmmtrzszmldj rn sqxqydyyzbdsln" + "fgpzmdycwfdtmypqwytjzzqjjrjhqbhzpjhnxxyydyhhnmfcpb" + "zpzzlzfmztzmyftskyjyjzhbzzygh pzcscsjssxfjgdyzyhzc" + "whcsexfqzywklytmlymqpxxskqjpxzhmhqyjs cjlqwhmybdhy" + "ylhlglcfytlxcjscpjskphjrtxteylssls yhxscznwtdwjslh" + "tqdjhgydphcqfzljlzptynlmjllqyshhylqqzypbywrfy js y" + "p yrhjnqtfwtwrchygmm yyhsmzhngcelqqmtcwcmpxjjfyysx" + "ztybmstsyjdtjqtlhynpyqzlcxznzmylflwby jgsylymzctdw" + "gszslmwzwwqzsayysssapxwcmgxhxdzyjgsjhygscyyxhbbzjk" + "ssmalxycfygmqyjycxjlljgczgqjcczotyxmtthlwtgfzkpzcx" + "kjycxctjcyh xsgckxzpsjpxhjwpjgsqxxsdmrszzyzwsykyzs" + "hbcsplwsscjhjlchhylhfhhxjsx lnylsdhzxysxlwzyhcldyh" + "zmdyspjtqznwqpsswctst zlmssmnyymjqjzwtyydchqlxkwbg" + "qybkfc jdlzllyylszydwhxpsbcmljscgbhxlqrljxysdwxzsl" + "df hlslymjljylyjcdrjlfsyjfnllcqyqfjy szlylmstdjcyh" + "zllnwlxxygyygxxhhzzxczqzfnwpypkpypmlgxgg dxzzkzfbx" + "xlzptytswhzyxhqhxxxywzyswdmzkxhzphgchj lfjxptzthly" + "xcrhxshxkjxxzqdcqyl jlkhtxcwhjfwcfpqryqxyqy gpggsc" + "sxngkchkzxhflxjbyzwtsxxncyjjmwzjqrhfqsyljzgynslgtc" + "ybyxxwyhhxynsqymlywgyqbbzljlpsytjzhyzwlrorjkczjxxy" + "xchdyxyxxjddsqfxyltsfxlmtyjmjjyyxltcxqzqhzlyyxzh n" + "lrhxjcdyhlbrlmrllaxksllljlxxxlycry lccgjcmtlzllyzz" + "pcw jyzeckzdqyqpcjcyzmbbcydcnltrmfgyqbsygmdqqzmkql" + "pgtbqcjfkjcxbljmswmdt ldlppbxcwkcbjczhkphyyhzkzmp" + "jysylpnyyxdb"; private static final String GBK_4 = "kxxmzjxsttdzxxbzyshjpfxpqbyljqkyzzzwl zgfwyctjxjpy" + "yspmsmydyshqy zchmjmcagcfbbhplxtyqx djgxdhkxxnbhrm" + "lnjsltsmrnlxqjyzlsqglbhdcgyqyyhwfjybbyjyjjdpqyapfx" + "cgjscrssyz lbzjjjlgxzyxyxsqkxbxxgcxpld wetdwwcjmbt" + "xchxyxxfxllj fwdpzsmylmwytcbcecblgdbqzqfjdjhymcxtx" + "drmjwrh xcjzylqdyhlsrsywwzjymtllltqcjzbtckzcyqjzqa" + "lmyhwwdxzxqdllqsgjfjljhjazdjgtkhsstcyjfpszlxzxrwgl" + "dlzr lzqtgslllllyxxqgdzybphl x bpfd hy jcc dmzpp" + "z cyqxldozlwdwyythcqsccrsslfzfp qmbjxlmyfgjb m jwd" + "n mmjtgbdzlp hsymjyl hdzjcctlcl ljcpddqdsznbgzxxcx" + "qycbzxzfzfjsnttjyhtcmjxtmxspdsypzgmljtycbmdkycsz z" + "yfyctgwhkyjxgyclndzscyzssdllqflqllxfdyhxggnywyllsd" + "lbbjcyjzmlhl xyyytdlllb b bqjzmpclmjpgehbcqax hhhz" + "chxyhjaxhlphjgpqqzgjjzzgzdqybzhhbwyffqdlzljxjpalxz" + "daglgwqyxxxfmmsypfmxsyzyshdzkxsmmzzsdnzcfp ltzdnmx" + "zymzmmxhhczjemxxksthwlsqlzllsjphlgzyhmxxhgzcjmhxtx" + "fwkmwkdthmfzzydkmsclcmghsxpslcxyxmkxyah jzmcsnxyym" + "mpmlgxmhlmlqmxtkzqyszjshyzjzybdqzwzqkdjlfmekzjpezs" + "wjmzyltemznplplbpykkqzkeqlwayyplhhaq jkqclhyxxmlyc" + "cyskg lcnszkyzkcqzqljpmzhxlywqlnrydtykwszdxddntqd" + "fqqmgseltthpwtxxlwydlzyzcqqpllkcc ylbqqczcljslzjxd" + "dbzqdljxzqjyzqkzljcyqdypp pqykjyrpcbymxkllzllfqpyl" + "llmsglcyrytmxyzfdzrysyztfmsmcl ywzgxzggsjsgkdtggzl" + "ldzbzhyyzhzywxyzymsdbzyjgtsmtfxqyjssdgslnndlyzzlrx" + "trznzxnqfmyzjzykbpnlypblnzz jhtzkgyzzrdznfgxskgjtt" + "yllgzzbjzklplzylxyxbjfpnjzzxcdxzyxzggrs jksmzjlsjy" + "wq yhqjxpjzt lsnshrnypzt wchklpszlcyysjylybbwzpdwg" + "cyxckdzxsgzwwyqyytctdllxwkczkkcclgcqqdzlqcsfqchqhs" + "fmqzlnbbshzdysjqplzcd cwjkjlpcmz jsqyzyhcpydsdzngq" + "mbsflnffgfsm q lgqcyybkjsrjhzldcftlljgjhtxzcszztjg" + "gkyoxblzppgtgyjdhz zzllqfzgqjzczbxbsxpxhyyclwdqjjx" + "mfdfzhqqmqg yhtycrznqxgpdzcszcljbhbzcyzzppyzzsgyhc" + "kpzjljnsc sllxb mstldfjmkdjslxlsz p pgjllydszgql l" + "kyyhzttnt tzzbsz ztlljtyyll llqyzqlbdzlslyyzyfszs" + "nhnc bbwsk rbc zm gjmzlshtslzbl q xflyljqbzg st" + "bmzjlxfnb xjztsfjmssnxlkbhsjxtnlzdntljjgzjyjczxygy" + "hwrwqnztn fjszpzshzjfyrdjfcjzbfzqchzxfxsbzqlzsgyft" + "zdcszxzjbqmszkjrhyjzckmjkhchgtxkjqalxbxfjtrtylxjhd" + "tsjx j jjzmzlcqsbtxhqgxtxxhxftsdkfjhzxjfj zcdlllt" + "qsqzqwqxswtwgwbccgzllqzbclmqqtzhzxzxljfrmyzflxys x" + "xjk xrmqdzdmmyxbsqbhgcmwfwtgmxlzpyytgzyccddyzxs g " + "yjyznbgpzjcqswxcjrtfycgrhztxszzt cbfclsyxzlzqmzlmp" + " lxzjxslbysmqhxxz rxsqzzzsslyflczjrcrxhhzxq dshjsj" + "jhqcxjbcynsssrjbqlpxqpymlxzkyxlxcjlcycxxzzlxlll hr" + "zzdxytyxcxff bpxdgygztcqwyltlswwsgzjmmgtjfsgzyafsm" + "lpfcwbjcljmzlpjjlmdyyyfbygyzgyzyrqqhxy kxygy fsfsl" + "nqhcfhccfxblplzyxxxkhhxshjzscxczwhhhplqalpqahxdlgg" + "gdrndtpyqjjcljzljlhyhyqydhz zczywteyzxhsl jbdgwxpc" + " tjckllwkllcsstknzdnqnttlzsszyqkcgbhcrrychfpfyrwq" + "pxxkdbbbqtzkznpcfxmqkcypzxehzkctcmxxmx nwwxjyhlstm" + "csqdjcxctcnd p lccjlsblplqcdnndscjdpgwmrzclodansyz" + "rdwjjdbcxwstszyljpxloclgpcjfzljyl c cnlckxtpzjwcyx" + "wfzdknjcjlltqcbxnw xbxklylhzlqzllzxwjljjjgcmngjdzx" + "txcxyxjjxsjtstp ghtxdfptffllxqpk fzflylybqjhzbmddb" + "cycld tddqlyjjwqllcsjpyyclttjpycmgyxzhsztwqwrfzhjg" + "azmrhcyy ptdlybyznbbxyxhzddnh msgbwfzzjcyxllrzcyxz" + "lwjgcggnycpmzqzhfgtcjeaqcpjcs dczdwldfrypysccwbxgz" + "mzztqscpxxjcjychcjwsnxxwjn mt mcdqdcllwnk zgglcczm" + "lbqjqdsjzzghqywbzjlttdhhcchflsjyscgc zjbypbpdqkxwy" + "yflxncwcxbmaykkjwzzzrxy yqjfljphhhytzqmhsgzqwbwjdy" + "sqzxslzyymyszg x hysyscsyznlqyljxcxtlwdqzpcycyppnx" + "fyrcmsmslxglgctlxzgz g tc dsllyxmtzalcpxjtjwtcyyjb" + "lbzlqmylxpghdlssdhbdcsxhamlzpjmcnhjysygchskqmc lwj" + "xsmocdrlyqzhjmyby lyetfjfrfksyxftwdsxxlysjslyxsnxy" + "yxhahhjzxwmljcsqlkydztzsxfdxgzjksxybdpwnzwpczczeny" + "cxqfjykbdmljqq lxslyxxylljdzbsmhpsttqqwlhogyblzzal" + "xqlzerrqlstmypyxjjxqsjpbryxyjlxyqylthylymlkljt llh" + "fzwkhljlhlj klj tlqxylmbtxchxcfxlhhhjbyzzkbxsdqc j" + "zsyhzxfebcqwyyjqtzyqhqqzmwffhfrbntpcjlfzgppxdbbztg" + " gchmfly xlxpqsywmngqlxjqjtcbhxspxlbyyjddhsjqyjxll" + "dtkhhbfwdysqrnwldebzwcydljtmxmjsxyrwfymwrxxysztzzt" + "ymldq xlyq jtscxwlprjwxhyphydnxhgmywytzcs tsdlwdcq" + "pyclqyjwxwzzmylclmxcmzsqtzpjqblgxjzfljjytjnxmcxs c" + "dl dyjdqcxsqyclzxzzxmxqrjhzjphfljlmlqnldxzlllfypny" + "ysxcqqcmjzzhnpzmekmxkyqlxstxxhwdcwdzgyyfpjzdyzjzx " + "rzjchrtlpyzbsjhxzypbdfgzzrytngxcqy b cckrjjbjerzgy" + " xknsjkljsjzljybzsqlbcktylccclpfyadzyqgk tsfc xdk" + "dyxyfttyh wtghrynjsbsnyjhkllslydxxwbcjsbbpjzjcjdz" + "bfxxbrjlaygcsndcdszblpz dwsbxbcllxxlzdjzsjy lyxfff" + "bhjjxgbygjpmmmpssdzjmtlyzjxswxtyledqpjmygqzjgdblqj" + "wjqllsdgytqjczcjdzxqgsgjhqxnqlzbxsgzhcxy ljxyxydfq" + "qjjfxdhctxjyrxysqtjxyebyyssyxjxncyzxfxmsyszxy schs" + "hxzzzgzcgfjdltynpzgyjyztyqzpbxcbdztzc zyxxyhhsqxsh" + "dhgqhjhgxwsztmmlhyxgcbtclzkkwjzrclekxtdbcykqqsayxc" + "jxwwgsbhjyzs csjkqcxswxfltynytpzc czjqtzwjqdzzzqz" + "ljjxlsbhpyxxpsxshheztxfptjqyzzxhyaxncfzyyhxgnxmywx" + "tcspdhhgymxmxqcxtsbcqsjyxxtyyly pclmmszmjzzllcogxz" + "aajzyhjmzxhdxzsxzdzxleyjjzjbhzmzzzqtzpsxztdsxjjlny" + "azhhyysrnqdthzhayjyjhdzjzlsw cltbzyecwcycrylcxnhzy" + "dzydtrxxbzsxqhxjhhlxxlhdlqfdbsxfzzyychtyyjbhecjkgj" + "fxhzjfxhwhdzfyapnpgnymshk mamnbyjtmxyjcthjbzyfcgty" + "hwphftwzzezsbzegpbmtskftycmhbllhgpzjxzjgzjyxzsbbqs" + "czzlzccstpgxmjsftcczjz djxcybzlfcjsyzfgszlybcwzzby" + "zdzypswyjgxzbdsysxlgzybzfyxxxccxtzlsqyxzjqdcztdxzj" + "jqcgxtdgscxzsyjjqcc ldqztqchqqjzyezwkjcfypqtynlmkc" + "qzqzbqnyjddzqzxdpzjcdjstcjnxbcmsjqmjqwwjqnjnlllwqc" + "qqdzpzydcydzcttf znztqzdtjlzbclltdsxkjzqdpzlzntjxz" + "bcjltqjldgdbbjqdcjwynzyzcdwllxwlrxntqqczxkjld tdgl" + " lajjkly kqll dz td ycggjyxdxfrskstqdenqmrkq hgkd" + "ldazfkypbggpzrebzzykyqspegjjglkqzzzslysywqzwfqzylz" + "zlzhwcgkyp qgnpgblplrrjyxcccyyhsbzfybnyytgzxylxczw" + "h zjzblfflgskhyjzeyjhlplllldzlyczblcybbxbcbpnnzc r" + " sycgyy qzwtzdxtedcnzzzty hdynyjlxdjyqdjszwlsh lbc" + "zpyzjyctdyntsyctszyyegdw ycxtscysmgzsccsdslccrqxyy" + "elsm xztebblyylltqsyrxfkbxsychbjbwkgskhhjh xgnlycd" + "lfyljgbxqxqqzzplnypxjyqymrbsyyhkxxstmxrczzywxyhymc" + "l lzhqwqxdbxbzwzmldmyskfmklzcyqyczqxzlyyzmddz ftqp" + "czcyypzhzllytztzxdtqcy ksccyyazjpcylzyjtfnyyynrs y" + "lmmnxjsmyb sljqyldzdpqbzzblfndsqkczfywhgqmrdsxycyt" + "xnq jpyjbfcjdyzfbrxejdgyqbsrmnfyyqpghyjdyzxgr htk " + "leq zntsmpklbsgbpyszbydjzsstjzytxzphsszsbzczptqfzm" + "yflypybbjgxzmxxdjmtsyskkbzxhjcelbsmjyjzcxt mljshrz" + "zslxjqpyzxmkygxxjcljprmyygadyskqs dhrzkqxzyztcghyt" + "lmljxybsyctbhjhjfcwzsxwwtkzlxqshlyjzjxe mplprcglt " + "zztlnjcyjgdtclklpllqpjmzbapxyzlkktgdwczzbnzdtdyqzj" + "yjgmctxltgcszlmlhbglk njhdxphlfmkyd lgxdtwzfrjejz" + "tzhydxykshwfzcqshknqqhtzhxmjdjskhxzjzbzzxympagjmst" + "bxlskyynwrtsqlscbpspsgzwyhtlksssw hzzlyytnxjgmjszs" + "xfwnlsoztxgxlsmmlbwldszylkqcqctmycfjbslxclzzclxxks" + "bjqclhjpsqplsxxckslnhpsfqqytxy jzlqldtzqjzdyydjnzp" + "d cdskjfsljhylzsqzlbtxxdgtqbdyazxdzhzjnhhqbyknxjjq" + "czmlljzkspldsclbblzkleljlbq ycxjxgcnlcqplzlznjtzlx" + "yxpxmyzxwyczyhzbtrblxlcczjadjlmmmsssmybhb kkbhrsxx" + "jmxsdynzpelbbrhwghfchgm klltsjyycqltskywyyhywxbxq" + "ywbawykqldq tmtkhqcgdqktgpkxhcpthtwthkshthlxyzyyda" + "spkyzpceqdltbdssegyjq xcwxssbz dfydlyjcls yzyexcyy" + "sdwnzajgyhywtjdaxysrltdpsyxfnejdy lxllqzyqqhgjhzyc" + "shwshczyjxllnxzjjn fxmfpycyawddhdmczlqzhzyztldywll" + "hymmylmbwwkxydtyldjpyw xjwmllsafdllyflb bqtzcqlj" + "tfmbthydcqrddwr qnysnmzbyytbjhp ygtjahg tbstxkbtzb" + "kldbeqqhqmjdyttxpgbktlgqxjjjcthxqdwjlwrfwqgwqhckry" + "swgftgygbxsd wdfjxxxjzlpyyypayxhydqkxsaxyxgskqhykf" + "dddpplcjlhqeewxksyykdbplfjtpkjltcyyhhjttpltzzcdlsh" + "qkzjqyste eywyyzy xyysttjkllpwmcyhqgxyhcrmbxpllnqt" + "jhyylfd fxzpsftljxxjbswyysksflxlpplbbblbsfxyzsylff" + "fscjds tztryysyffsyzszbjtbctsbsdhrtjjbytcxyje xbne" + "bjdsysykgsjzbxbytfzwgenhhhhzhhtfwgzstbgxklsty mtmb" + "yxj skzscdyjrcwxzfhmymcxlzndtdh xdjggybfbnbpthfjaa" + "xwfpxmyphdttcxzzpxrsywzdlybbjd qwqjpzypzjznjpzjlzt" + " fysbttslmptzrtdxqsjehbzyj dhljsqmlhtxtjecxslzzspk" + "tlzkqqyfs gywpcpqfhqhytqxzkrsg gsjczlptxcdyyzss qz" + "slxlzmycbcqbzyxhbsxlzdltcdjtylzjyyzpzylltxjsjxhlbr" + "ypxqzskswwwygyabbztqktgpyspxbjcmllxztbklgqkq lsktf" + "xrdkbfpftbbrfeeqgypzsstlbtpszzsjdhlqlzpmsmmsxlqqnk" + "nbrddnxxdhddjyyyfqgzlxsmjqgxytqlgpbqxcyzy drj gtdj" + "yhqshtmjsbwplwhlzffny gxqhpltbqpfbcwqdbygpnztbfzj" + "gsdctjshxeawzzylltyybwjkxxghlfk djtmsz sqynzggswqs" + "phtlsskmcl yszqqxncjdqgzdlfnykljcjllzlmzjn scht" + "hxzlzjbbhqzwwycrdhlyqqjbeyfsjxwhsr wjhwpslmssgztt" + "ygyqqwr lalhmjtqjcmxqbjjzjxtyzkxbyqxbjxshzssfjlxmx" + " fghkzszggylcls rjyhslllmzxelgl xdjtbgyzbpktzhkzj" + "yqsbctwwqjpqwxhgzgdyfljbyfdjf hsfmbyzhqgfwqsyfyjgp" + "hzbyyzffwodjrlmftwlbzgycqxcdj ygzyyyyhy xdwegazyhx" + "jlzythlrmgrxxzcl ljjtjtbwjybjjbxjjtjteekhwslj lp" + "sfyzpqqbdlqjjtyyqlyzkdksqj yyqzldqtgjj js cmraqth" + "tejmfctyhypkmhycwj cfhyyxwshctxrljhjshccyyyjltktty" + "tmxgtcjtzaxyoczlylbszyw jytsjyhbyshfjlygjxxtmzyylt" + "xxypzlxyjzyzyybnhmymdyylblhlsyygqllscxlxhdwkqgyshq" + "ywljyyhzmsljljxcjjyy cbcpzjmylcqlnjqjlxyjmlzjqlycm" + "hcfmmfpqqmfxlmcfqmm znfhjgtthkhchydxtmqzymyytyyyzz" + "dcymzydlfmycqzwzz mabtbcmzzgdfycgcytt fwfdtzqssstx" + "jhxytsxlywwkxexwznnqzjzjjccchyyxbzxzcyjtllcqxynjyc" + "yycynzzqyyyewy czdcjyhympwpymlgkdldqqbchjxy " + " " + " sypszsjczc cqytsjljjt "; /** * 获取GBK字的拼音的首字母 * 由于数据较大,完整的GBK编码表按GBK规范分成3部分 * GBK/2为与GB2312兼容的国标汉字部分,GBK/3和GBK/4为扩展汉字部分 * 每一部分都有自己的地址计算公式 * 若输入是acsii则返回同样的acsii * 若输入是中文字符则返回拼音的首字母 * 若输入是中文字符但是该字符不知道如何发音,则返回空字符 * @param hzString * @return String * @throws UnsupportedEncodingException */ public static String getGBKpy(String hzString) throws UnsupportedEncodingException { /* * 效率:处理大字符串(字符串有132055个byte,即70577个char)1000次,消耗时间44.474S. */ if (hzString == null || hzString.length() == 0) return ""; int pyi, len, no; int ch1code = 0, ch2code = 0; char ch1, ch2; StringBuffer pyBuffer = new StringBuffer(); byte eB[] = hzString.getBytes("GBK"); len = eB.length; //开始计算 pyi = 0; while (pyi < len) { ch1 = (char) eB[pyi]; pyi = pyi + 1; ch1code = ch1; if (ch1code > 0 && ch1code < 129) { //普通的acsii pyBuffer.append(ch1); continue; } else { //GBK字符 ch1 = (char) (256 + (int) ch1); if (eB[pyi] < 0) { ch2 = (char) (256 + (int) eB[pyi]); } else { ch2 = (char) eB[pyi]; } pyi = pyi + 1; if (pyi > len) break; } ch1code = ch1; ch2code = ch2; if (ch1code <= 254 && ch1code >= 170) { //优先处理GB-2312汉字. if (ch2code > 160) { //查找GB-2312 no = (ch1code - 176) * 94 + (ch2code - 160); pyBuffer.append(GB_2312.charAt(no - 1)); } else { //查找GBK_4 no = (ch1code - 170) * 97 + (ch2code - 63); pyBuffer.append(GBK_4.charAt(no - 1)); } }else if (ch1code <= 160 && ch1code >= 129) { //查找GBK_3 no = (ch1code - 129) * 191 + (ch2code - 63); pyBuffer.append(GBK_3.charAt(no - 1)); } else { //不是GBK汉字 continue; } } return pyBuffer.toString().trim().toLowerCase(); } public static void main(String[] args) throws Exception{ System.out.println(GetPy.getGBKpy("光谷金融港镕軍國")); } }
相关推荐
获取GBK字的拼音的首字母 由于数据较大,完整的GBK编码表按GBK规范分成3部分 GBK/2为与GB2312兼容的国标汉字部分,GBK/3和GBK/4为扩展汉字部分 每一部分都有自己的地址计算公式 若输入是acsii则返回同样的acsii 若...
总的来说,Java中获取汉字的拼音、部首、笔画和笔画数目需要结合使用特定的库和自定义的处理逻辑。这涉及到对汉字编码、自然语言处理以及数据结构的理解。HanDict文件则可能是提供这类信息的关键,它可能包含了汉字...
这个“查询中文拼音首字母”的功能主要涉及到中文字符编码、汉字拼音库以及编程技术等方面的知识点。 首先,我们需要了解中文字符的编码方式。在计算机中,中文字符通常使用UTF-8或GBK等编码格式存储。UTF-8是...
- 使用拼音库的方法,例如Pinyin4j,首先需要将汉字转换为Unicode编码,然后调用库中的方法获取拼音,再提取首字母。 6. **应用场景**: - 搜索优化:在搜索引擎中,通过首字母快速定位到目标汉字,提高搜索效率...
为了获取汉字的首字母,我们可以利用Java的内置类`Character`来获取汉字的拼音首字母。以下是一个简单的示例: ```java public static String getFirstChar(String chinese) { char[] chars = chinese.toCharArray...
在中文环境中,为了方便用户根据汉字的拼音首字母进行快速查找,这种查询方式尤其有用。Oracle数据库虽然原生支持英文字符集,但通过特定的方法,也可以处理中文字符集并实现拼音查询功能。以下将详细阐述这一主题。...
标题中的“取汉字拼音首字母工具源码”指的是一个编程工具,它的主要功能是将汉字转化为对应的拼音首字母。在中文处理中,这种技术常用于快速检索、关键词提取或者建立汉字与拼音之间的索引。例如,在搜索引擎中,...
在网页开发中,有时我们需要为用户提供输入汉字的功能,并且能够实时获取这些汉字的拼音首字母,这在构建搜索功能或实现特定的用户交互时尤其有用。"JS汉字拼音首字母自动获取代码"就是一个解决此类需求的JavaScript...
另一方面,汉字转拼音首字母则是获取每个汉字的首字母,这种技术常用于快速检索或创建基于拼音的排序系统,如联系人列表排序。 在JavaScript中,由于JavaScript本身并不内置汉字转拼音的函数,我们需要借助第三方库...
这可以通过预处理大量汉字与拼音的对应关系来完成,例如GB2312或GBK编码中的汉字与拼音对照。 2. **多音字处理**:有些汉字有多个读音,如“还”可以读作“hái”或“huán”。处理这种情况时,通常会提供所有可能...
2. **利用编码表或库函数**:可以通过建立一个汉字与拼音首字母的对照表,或者使用支持汉字到拼音转换的库函数,来获取每个汉字的拼音首字母。 3. **循环处理字符串**:对于给定的字符串,需遍历每一个字符,使用...
根据提供的信息,我们可以了解到这段Java代码的主要目的是将中文字符转换为对应的汉语拼音首字母。这种方法在处理中文排序、检索等场景时非常有用。下面将详细解释该代码的工作原理及其应用场景。 ### 代码逻辑分析...
在IT领域,尤其是在编程实践中,有时我们需要将汉字转换为它们的首字母或拼音,以便进行数据处理、搜索优化或其他特定用途。VB(Visual Basic)是一种流行的编程语言,它提供了丰富的库和工具来处理字符串和字符操作...
而将汉字转换为拼音,就需要借助特定的算法和字典库,比如Pinyin4j在Java中的应用,或者在Oracle中使用预定义的函数和存储过程。 在Oracle中,由于没有内置的汉字转拼音功能,我们需要自己编写存储过程。"pkg_...
对于需要获取拼音首字母的情况,可以先获取全拼,然后取每个拼音的首字母。例如,`"北京".charAt(0)`获取“北”的字符,`pinyin.charAt(0)`获取其首字母。 在实际应用中,pinyin4j可以用来做关键词提取、拼音排序...
3. **GBK编码法**:对于使用GBK等非Unicode编码的系统,可以通过解析GBK编码来获取汉字的拼音首字母。GBK编码包含了汉字的拼音信息,但处理起来比Unicode复杂。 4. **AI算法**:近年来,随着人工智能的发展,一些...
在实现过程中,你需要遍历数据列表,对每个中文字符串获取拼音首字母,然后根据这些首字母创建一个分组。每个分组可以作为一个SectionHeader,显示对应的拼音首字母,下面跟着对应首字母的所有项。ListView可以通过...
在计算机编程中,将汉字转换为拼音首字母是一项基础任务,通常用于实现如中文键盘输入法、关键词提取、文本分类等。这种转换技术涉及到汉字编码、拼音数据库、字符串处理等多种技术。 首先,我们需要了解汉字与...
在计算机中,汉字是以Unicode编码存储的,而Unicode编码与汉字的拼音首字母之间存在一定的转换规则。通常,我们可以通过汉字的GBK或UTF-8编码来转换得到对应的拼音。例如,使用Pinyin4j这样的Java库,或者Python中的...