xshrimp 发表于 2012-6-13 14:55:56

汉字转拼音

;;;汉字库分布情况如下:
;;;一级汉字 16-55区
;;;二级汉字 56-87区
;;;三级汉字 1-9区
;;;空闲未用 10-15区
;;;
;;;一级字库3755个汉字,通常占使用汉字的90%左右.按照拼音字母顺序排列的,
;;;二级汉字是以偏旁部首顺序排列的

;;;gb2312字库.http://ash.jp/code/cn/gb2312tbl.htm

;;; xshrimp 2012.06.13
;;;下面的程序可以将一级字库内的汉字翻译为拼音,多音字未考虑.
;;;二级汉字以偏旁部首顺序排列不知道怎么翻译,希望有能力的继续完善!

(defun py (key / lst to)                                       
(setq lst (vl-string->list key))
(setq to (+ (* 256 (car lst)) (cadr lst) -65536))
(cond
((<= -20319 To -20318)
    "a"
)
((<= -20317 To -20305)
    "ai"
)
((<= -20304 To -20296)
    "an"
)
((<= -20295 To -20293)
    "ang"
)
((<= -20292 To -20284)
    "ao"
)
((<= -20283 To -20266)
    "ba"
)
((<= -20265 To -20258)
    "bai"
)
((<= -20257 To -20243)
    "ban"
)
((<= -20242 To -20231)
    "bang"
)
((<= -20230 To -20052)
    "bao"
)
((<= -20051 To -20037)
    "bei"
)
((<= -20036 To -20033)
    "ben"
)
((<= -20032 To -20027)
    "beng"
)
((<= -20026 To -20003)
    "bi"
)
((<= -20002 To -19991)
    "bian"
)
((<= -19990 To -19987)
    "biao"
)
((<= -19986 To -19983)
    "bie"
)
((<= -19982 To -19977)
    "bin"
)
((<= -19976 To -19806)
    "bing"
)
((<= -19805 To -19785)
    "bo"
)
((<= -19784 To -19776)
    "bu"
)
((<= -19775 To -19775)
    "ca"
)
((<= -19774 To -19764)
    "cai"
)
((<= -19763 To -19757)
    "can"
)
((<= -19756 To -19752)
    "cang"
)
((<= -19751 To -19747)
    "cao"
)
((<= -19746 To -19742)
    "ce"
)
((<= -19741 To -19740)
    "ceng"
)
((<= -19739 To -19729)
    "cha"
)
((<= -19728 To -19726)
    "chai"
)
((<= -19725 To -19716)
    "chan"
)
((<= -19715 To -19541)
    "chang"
)
((<= -19540 To -19532)
    "chao"
)
((<= -19531 To -19526)
    "che"
)
((<= -19525 To -19516)
    "chen"
)
((<= -19515 To -19501)
    "cheng"
)
((<= -19500 To -19485)
    "chi"
)
((<= -19484 To -19480)
    "chong"
)
((<= -19479 To -19468)
    "chou"
)
((<= -19467 To -19290)
    "chu"
)
((<= -19289 To -19289)
    "chuai"
)
((<= -19288 To -19282)
    "chuan"
)
((<= -19281 To -19276)
    "chuang"
)
((<= -19275 To -19271)
    "chui"
)
((<= -19270 To -19264)
    "chun"
)
((<= -19263 To -19262)
    "chuo"
)
((<= -19261 To -19250)
    "ci"
)
((<= -19249 To -19244)
    "cong"
)
((<= -19243 To -19243)
    "cou"
)
((<= -19242 To -19239)
    "cu"
)
((<= -19238 To -19236)
    "cuan"
)
((<= -19235 To -19228)
    "cui"
)
((<= -19227 To -19225)
    "cun"
)
((<= -19224 To -19219)
    "cuo"
)
((<= -19218 To -19213)
    "da"
)
((<= -19212 To -19039)
    "dai"
)
((<= -19038 To -19024)
    "dan"
)
((<= -19023 To -19019)
    "dang"
)
((<= -19018 To -19007)
    "dao"
)
((<= -19006 To -19004)
    "de"
)
((<= -19003 To -18997)
    "deng"
)
((<= -18996 To -18978)
    "di"
)
((<= -18977 To -18962)
    "dian"
)
((<= -18961 To -18953)
    "diao"
)
((<= -18952 To -18784)
    "die"
)
((<= -18783 To -18775)
    "ding"
)
((<= -18774 To -18774)
    "diu"
)
((<= -18773 To -18764)
    "dong"
)
((<= -18763 To -18757)
    "dou"
)
((<= -18756 To -18742)
    "du"
)
((<= -18741 To -18736)
    "duan"
)
((<= -18735 To -18732)
    "dui"
)
((<= -18731 To -18723)
    "dun"
)
((<= -18722 To -18711)
    "duo"
)
((<= -18710 To -18698)
    "e"
)
((<= -18697 To -18697)
    "en"
)
((<= -18696 To -18527)
    "er"
)
((<= -18526 To -18519)
    "fa"
)
((<= -18518 To -18502)
    "fan"
)
((<= -18501 To -18491)
    "fang"
)
((<= -18490 To -18479)
    "fei"
)
((<= -18478 To -18464)
    "fen"
)
((<= -18463 To -18449)
    "feng"
)
((<= -18448 To -18448)
    "fo"
)
((<= -18447 To -18447)
    "fou"
)
((<= -18446 To -18240)
    "fu"
)
((<= -18239 To -18238)
    "ga"
)
((<= -18237 To -18232)
    "gai"
)
((<= -18231 To -18221)
    "gan"
)
((<= -18220 To -18212)
    "gang"
)
((<= -18211 To -18202)
    "gao"
)
((<= -18201 To -18185)
    "ge"
)
((<= -18184 To -18184)
    "gei"
)
((<= -18183 To -18182)
    "gen"
)
((<= -18181 To -18013)
    "geng"
)
((<= -18012 To -17998)
    "gong"
)
((<= -17997 To -17989)
    "gou"
)
((<= -17988 To -17971)
    "gu"
)
((<= -17970 To -17965)
    "gua"
)
((<= -17964 To -17962)
    "guai"
)
((<= -17961 To -17951)
    "guan"
)
((<= -17950 To -17948)
    "guang"
)
((<= -17947 To -17932)
    "gui"
)
((<= -17931 To -17929)
    "gun"
)
((<= -17928 To -17923)
    "guo"
)
((<= -17922 To -17760)
    "ha"
)
((<= -17759 To -17753)
    "hai"
)
((<= -17752 To -17734)
    "han"
)
((<= -17733 To -17731)
    "hang"
)
((<= -17730 To -17722)
    "hao"
)
((<= -17721 To -17704)
    "he"
)
((<= -17703 To -17702)
    "hei"
)
((<= -17701 To -17698)
    "hen"
)
((<= -17697 To -17693)
    "heng"
)
((<= -17692 To -17684)
    "hong"
)
((<= -17683 To -17677)
    "hou"
)
((<= -17676 To -17497)
    "hu"
)
((<= -17496 To -17488)
    "hua"
)
((<= -17487 To -17483)
    "huai"
)
((<= -17482 To -17469)
    "huan"
)
((<= -17468 To -17455)
    "huang"
)
((<= -17454 To -17434)
    "hui"
)
((<= -17433 To -17428)
    "hun"
)
((<= -17427 To -17418)
    "huo"
)
((<= -17417 To -17203)
    "ji"
)
((<= -17202 To -17186)
    "jia"
)
((<= -17185 To -16984)
    "jian"
)
((<= -16983 To -16971)
    "jiang"
)
((<= -16970 To -16943)
    "jiao"
)
((<= -16942 To -16916)
    "jie"
)
((<= -16915 To -16734)
    "jin"
)
((<= -16733 To -16709)
    "jing"
)
((<= -16708 To -16707)
    "jiong"
)
((<= -16706 To -16690)
    "jiu"
)
((<= -16689 To -16665)
    "ju"
)
((<= -16664 To -16658)
    "juan"
)
((<= -16657 To -16648)
    "jue"
)
((<= -16647 To -16475)
    "jun"
)
((<= -16474 To -16471)
    "ka"
)
((<= -16470 To -16466)
    "kai"
)
((<= -16465 To -16460)
    "kan"
)
((<= -16459 To -16453)
    "kang"
)
((<= -16452 To -16449)
    "kao"
)
((<= -16448 To -16434)
    "ke"
)
((<= -16433 To -16430)
    "ken"
)
((<= -16429 To -16428)
    "keng"
)
((<= -16427 To -16424)
    "kong"
)
((<= -16423 To -16420)
    "kou"
)
((<= -16419 To -16413)
    "ku"
)
((<= -16412 To -16408)
    "kua"
)
((<= -16407 To -16404)
    "kuai"
)
((<= -16403 To -16402)
    "kuan"
)
((<= -16401 To -16394)
    "kuang"
)
((<= -16393 To -16221)
    "kui"
)
((<= -16220 To -16217)
    "kun"
)
((<= -16216 To -16213)
    "kuo"
)
((<= -16212 To -16206)
    "la"
)
((<= -16205 To -16203)
    "lai"
)
((<= -16202 To -16188)
    "lan"
)
((<= -16187 To -16181)
    "lang"
)
((<= -16180 To -16172)
    "lao"
)
((<= -16171 To -16170)
    "le"
)
((<= -16169 To -16159)
    "lei"
)
((<= -16158 To -16156)
    "leng"
)
((<= -16155 To -15960)
    "li"
)
((<= -15959 To -15959)
    "lia"
)
((<= -15958 To -15945)
    "lian"
)
((<= -15944 To -15934)
    "liang"
)
((<= -15933 To -15921)
    "liao"
)
((<= -15920 To -15916)
    "lie"
)
((<= -15915 To -15904)
    "lin"
)
((<= -15903 To -15890)
    "ling"
)
((<= -15889 To -15879)
    "liu"
)
((<= -15878 To -15708)
    "long"
)
((<= -15707 To -15702)
    "lou"
)
((<= -15701 To -15682)
    "lu"
)
((<= -15681 To -15668)
    "lv"
)
((<= -15667 To -15662)
    "luan"
)
((<= -15661 To -15660)
    "lue"
)
((<= -15659 To -15653)
    "lun"
)
((<= -15652 To -15641)
    "luo"
)
((<= -15640 To -15632)
    "ma"
)
((<= -15631 To -15626)
    "mai"
)
((<= -15625 To -15455)
    "man"
)
((<= -15454 To -15449)
    "mang"
)
((<= -15448 To -15437)
    "mao"
)
((<= -15436 To -15436)
    "me"
)
((<= -15435 To -15420)
    "mei"
)
((<= -15419 To -15417)
    "men"
)
((<= -15416 To -15409)
    "meng"
)
((<= -15408 To -15395)
    "mi"
)
((<= -15394 To -15386)
    "mian"
)
((<= -15385 To -15378)
    "miao"
)
((<= -15377 To -15376)
    "mie"
)
((<= -15375 To -15370)
    "min"
)
((<= -15369 To -15364)
    "ming"
)
((<= -15363 To -15363)
    "miu"
)
((<= -15362 To -15184)
    "mo"
)
((<= -15183 To -15181)
    "mou"
)
((<= -15180 To -15166)
    "mu"
)
((<= -15165 To -15159)
    "na"
)
((<= -15158 To -15154)
    "nai"
)
((<= -15153 To -15151)
    "nan"
)
((<= -15150 To -15150)
    "nang"
)
((<= -15149 To -15145)
    "nao"
)
((<= -15144 To -15144)
    "ne"
)
((<= -15143 To -15142)
    "nei"
)
((<= -15141 To -15141)
    "nen"
)
((<= -15140 To -15140)
    "neng"
)
((<= -15139 To -15129)
    "ni"
)
((<= -15128 To -15122)
    "nian"
)
((<= -15121 To -15120)
    "niang"
)
((<= -15119 To -15118)
    "niao"
)
((<= -15117 To -15111)
    "nie"
)
((<= -15110 To -15110)
    "nin"
)
((<= -15109 To -14942)
    "ning"
)
((<= -14941 To -14938)
    "niu"
)
((<= -14937 To -14934)
    "nong"
)
((<= -14933 To -14931)
    "nu"
)
((<= -14930 To -14930)
    "nv"
)
((<= -14929 To -14929)
    "nuan"
)
((<= -14928 To -14927)
    "nue"
)
((<= -14926 To -14923)
    "nuo"
)
((<= -14922 To -14922)
    "o"
)
((<= -14921 To -14915)
    "ou"
)
((<= -14914 To -14909)
    "pa"
)
((<= -14908 To -14903)
    "pai"
)
((<= -14902 To -14895)
    "pan"
)
((<= -14894 To -14890)
    "pang"
)
((<= -14889 To -14883)
    "pao"
)
((<= -14882 To -14874)
    "pei"
)
((<= -14873 To -14872)
    "pen"
)
((<= -14871 To -14858)
    "peng"
)
((<= -14857 To -14679)
    "pi"
)
((<= -14678 To -14675)
    "pian"
)
((<= -14674 To -14671)
    "piao"
)
((<= -14670 To -14669)
    "pie"
)
((<= -14668 To -14664)
    "pin"
)
((<= -14663 To -14655)
    "ping"
)
((<= -14654 To -14646)
    "po"
)
((<= -14645 To -14631)
    "pu"
)
((<= -14630 To -14595)
    "qi"
)
((<= -14594 To -14430)
    "qia"
)
((<= -14429 To -14408)
    "qian"
)
((<= -14407 To -14400)
    "qiang"
)
((<= -14399 To -14385)
    "qiao"
)
((<= -14384 To -14380)
    "qie"
)
((<= -14379 To -14369)
    "qin"
)
((<= -14368 To -14356)
    "qing"
)
((<= -14355 To -14354)
    "qiong"
)
((<= -14353 To -14346)
    "qiu"
)
((<= -14345 To -14171)
    "qu"
)
((<= -14170 To -14160)
    "quan"
)
((<= -14159 To -14152)
    "que"
)
((<= -14151 To -14150)
    "qun"
)
((<= -14149 To -14146)
    "ran"
)
((<= -14145 To -14141)
    "rang"
)
((<= -14140 To -14138)
    "rao"
)
((<= -14137 To -14136)
    "re"
)
((<= -14135 To -14126)
    "ren"
)
((<= -14125 To -14124)
    "reng"
)
((<= -14123 To -14123)
    "ri"
)
((<= -14122 To -14113)
    "rong"
)
((<= -14112 To -14110)
    "rou"
)
((<= -14109 To -14100)
    "ru"
)
((<= -14099 To -14098)
    "ruan"
)
((<= -14097 To -14095)
    "rui"
)
((<= -14094 To -14093)
    "run"
)
((<= -14092 To -14091)
    "ruo"
)
((<= -14090 To -14088)
    "sa"
)
((<= -14087 To -14084)
    "sai"
)
((<= -14083 To -13918)
    "san"
)
((<= -13917 To -13915)
    "sang"
)
((<= -13914 To -13911)
    "sao"
)
((<= -13910 To -13908)
    "se"
)
((<= -13907 To -13907)
    "sen"
)
((<= -13906 To -13906)
    "seng"
)
((<= -13905 To -13897)
    "sha"
)
((<= -13896 To -13895)
    "shai"
)
((<= -13894 To -13879)
    "shan"
)
((<= -13878 To -13871)
    "shang"
)
((<= -13870 To -13860)
    "shao"
)
((<= -13859 To -13848)
    "she"
)
((<= -13847 To -13832)
    "shen"
)
((<= -13831 To -13659)
    "sheng"
)
((<= -13658 To -13612)
    "shi"
)
((<= -13611 To -13602)
    "shou"
)
((<= -13601 To -13407)
    "shu"
)
((<= -13406 To -13405)
    "shua"
)
((<= -13404 To -13401)
    "shuai"
)
((<= -13400 To -13399)
    "shuan"
)
((<= -13398 To -13396)
    "shuang"
)
((<= -13395 To -13392)
    "shui"
)
((<= -13391 To -13388)
    "shun"
)
((<= -13387 To -13384)
    "shuo"
)
((<= -13383 To -13368)
    "si"
)
((<= -13367 To -13360)
    "song"
)
((<= -13359 To -13357)
    "sou"
)
((<= -13356 To -13344)
    "su"
)
((<= -13343 To -13341)
    "suan"
)
((<= -13340 To -13330)
    "sui"
)
((<= -13329 To -13327)
    "sun"
)
((<= -13326 To -13319)
    "suo"
)
((<= -13318 To -13148)
    "ta"
)
((<= -13147 To -13139)
    "tai"
)
((<= -13138 To -13121)
    "tan"
)
((<= -13120 To -13108)
    "tang"
)
((<= -13107 To -13097)
    "tao"
)
((<= -13096 To -13096)
    "te"
)
((<= -13095 To -13092)
    "teng"
)
((<= -13091 To -13077)
    "ti"
)
((<= -13076 To -13069)
    "tian"
)
((<= -13068 To -13064)
    "tiao"
)
((<= -13063 To -13061)
    "tie"
)
((<= -13060 To -12889)
    "ting"
)
((<= -12888 To -12876)
    "tong"
)
((<= -12875 To -12872)
    "tou"
)
((<= -12871 To -12861)
    "tu"
)
((<= -12860 To -12859)
    "tuan"
)
((<= -12858 To -12853)
    "tui"
)
((<= -12852 To -12850)
    "tun"
)
((<= -12849 To -12839)
    "tuo"
)
((<= -12838 To -12832)
    "wa"
)
((<= -12831 To -12830)
    "wai"
)
((<= -12829 To -12813)
    "wan"
)
((<= -12812 To -12803)
    "wang"
)
((<= -12802 To -12608)
    "wei"
)
((<= -12607 To -12598)
    "wen"
)
((<= -12597 To -12595)
    "weng"
)
((<= -12594 To -12586)
    "wo"
)
((<= -12585 To -12557)
    "wu"
)
((<= -12556 To -12360)
    "xi"
)
((<= -12359 To -12347)
    "xia"
)
((<= -12346 To -12321)
    "xian"
)
((<= -12320 To -12301)
    "xiang"
)
((<= -12300 To -12121)
    "xiao"
)
((<= -12120 To -12100)
    "xie"
)
((<= -12099 To -12090)
    "xin"
)
((<= -12089 To -12075)
    "xing"
)
((<= -12074 To -12068)
    "xiong"
)
((<= -12067 To -12059)
    "xiu"
)
((<= -12058 To -12040)
    "xu"
)
((<= -12039 To -11868)
    "xuan"
)
((<= -11867 To -11862)
    "xue"
)
((<= -11861 To -11848)
    "xun"
)
((<= -11847 To -11832)
    "ya"
)
((<= -11831 To -11799)
    "yan"
)
((<= -11798 To -11782)
    "yang"
)
((<= -11781 To -11605)
    "yao"
)
((<= -11604 To -11590)
    "ye"
)
((<= -11589 To -11537)
    "yi"
)
((<= -11536 To -11359)
    "yin"
)
((<= -11358 To -11341)
    "ying"
)
((<= -11340 To -11340)
    "yo"
)
((<= -11339 To -11325)
    "yong"
)
((<= -11324 To -11304)
    "you"
)
((<= -11303 To -11098)
    "yu"
)
((<= -11097 To -11078)
    "yuan"
)
((<= -11077 To -11068)
    "yue"
)
((<= -11067 To -11056)
    "yun"
)
((<= -11055 To -11053)
    "za"
)
((<= -11052 To -11046)
    "zai"
)
((<= -11045 To -11042)
    "zan"
)
((<= -11041 To -11039)
    "zang"
)
((<= -11038 To -11025)
    "zao"
)
((<= -11024 To -11021)
    "ze"
)
((<= -11020 To -11020)
    "zei"
)
((<= -11019 To -11019)
    "zen"
)
((<= -11018 To -11015)
    "zeng"
)
((<= -11014 To -10839)
    "zha"
)
((<= -10838 To -10833)
    "zhai"
)
((<= -10832 To -10816)
    "zhan"
)
((<= -10815 To -10801)
    "zhang"
)
((<= -10800 To -10791)
    "zhao"
)
((<= -10790 To -10781)
    "zhe"
)
((<= -10780 To -10765)
    "zhen"
)
((<= -10764 To -10588)
    "zheng"
)
((<= -10587 To -10545)
    "zhi"
)
((<= -10544 To -10534)
    "zhong"
)
((<= -10533 To -10520)
    "zhou"
)
((<= -10519 To -10332)
    "zhu"
)
((<= -10331 To -10330)
    "zhua"
)
((<= -10329 To -10329)
    "zhuai"
)
((<= -10328 To -10323)
    "zhuan"
)
((<= -10322 To -10316)
    "zhuang"
)
((<= -10315 To -10310)
    "zhui"
)
((<= -10309 To -10308)
    "zhun"
)
((<= -10307 To -10297)
    "zhuo"
)
((<= -10296 To -10282)
    "zi"
)
((<= -10281 To -10275)
    "zong"
)
((<= -10274 To -10271)
    "zou"
)
((<= -10270 To -10263)
    "zu"
)
((<= -10262 To -10261)
    "zuan"
)
((<= -10260 To -10257)
    "zui"
)
((<= -10256 To -10255)
    "zun"
)
((<= -10254 To -10247)
    "zuo"
)
)
)


命令: (py "你")
"ni"
命令: (py "中")
"zhong"



flowerson 发表于 2021-10-2 16:56:00

楼主,这个方法在cad2021不行了,2018-2020是可以的。请脚楼主怎样调整?

flowerson 发表于 2021-10-2 12:56:51

cad2021这个方法又不行了。

Ming131564 发表于 2023-1-16 18:57:00

用来做交通标志牌很好用

xshrimp 发表于 2012-6-13 15:05:41

本帖最后由 xshrimp 于 2012-6-13 15:13 编辑

转:获取汉字的拼音(包括一级和二级)
http://hi.baidu.com/lixingxing/item/f587043ead574bf7df222164
这个是不是只能取得首字母??
谁懂java?翻译成lisp呢.谢谢

hgf876 发表于 2012-6-13 15:17:43

顶一下,不过不知道用在哪里

xshrimp 发表于 2012-6-13 15:21:09

例如做通讯录等要汉字支持首字母搜索等等啊.

zyhandw 发表于 2012-6-13 16:11:01

本帖最后由 zyhandw 于 2012-6-13 16:16 编辑

这也行啊,真是高手!
试了,挺好,不过字库不是很全,且不支持繁体,!

sfzyr 发表于 2012-6-13 21:06:04

这个有什么用了????

要是有音标就好了

我觉得还是百度查来的快,还有音标

haoryh 发表于 2012-9-8 11:40:54

牛X人啊,顶起

张和平 发表于 2013-7-21 00:02:28

sfzyr 发表于 2012-6-13 21:06 static/image/common/back.gif
这个有什么用了????

要是有音标就好了


排序用。。。。

328302216 发表于 2014-9-15 11:02:13

没有功劳也有苦劳!支持一下楼主!
页: [1] 2
查看完整版本: 汉字转拼音