pingyin.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <?php
  2. class pingyin_lib
  3. {
  4. var $pingying_d;
  5. function __construct()
  6. {
  7. $this->pingying_d=array(
  8. array("a",-20319),
  9. array("ai",-20317),
  10. array("an",-20304),
  11. array("ang",-20295),
  12. array("ao",-20292),
  13. array("ba",-20283),
  14. array("bai",-20265),
  15. array("ban",-20257),
  16. array("bang",-20242),
  17. array("bao",-20230),
  18. array("bei",-20051),
  19. array("ben",-20036),
  20. array("beng",-20032),
  21. array("bi",-20026),
  22. array("bian",-20002),
  23. array("biao",-19990),
  24. array("bie",-19986),
  25. array("bin",-19982),
  26. array("bing",-19976),
  27. array("bo",-19805),
  28. array("bu",-19784),
  29. array("ca",-19775),
  30. array("cai",-19774),
  31. array("can",-19763),
  32. array("cang",-19756),
  33. array("cao",-19751),
  34. array("ce",-19746),
  35. array("ceng",-19741),
  36. array("cha",-19739),
  37. array("chai",-19728),
  38. array("chan",-19725),
  39. array("chang",-19715),
  40. array("chao",-19540),
  41. array("che",-19531),
  42. array("chen",-19525),
  43. array("cheng",-19515),
  44. array("chi",-19500),
  45. array("chong",-19484),
  46. array("chou",-19479),
  47. array("chu",-19467),
  48. array("chuai",-19289),
  49. array("chuan",-19288),
  50. array("chuang",-19281),
  51. array("chui",-19275),
  52. array("chun",-19270),
  53. array("chuo",-19263),
  54. array("ci",-19261),
  55. array("cong",-19249),
  56. array("cou",-19243),
  57. array("cu",-19242),
  58. array("cuan",-19238),
  59. array("cui",-19235),
  60. array("cun",-19227),
  61. array("cuo",-19224),
  62. array("da",-19218),
  63. array("dai",-19212),
  64. array("dan",-19038),
  65. array("dang",-19023),
  66. array("dao",-19018),
  67. array("de",-19006),
  68. array("deng",-19003),
  69. array("di",-18996),
  70. array("dian",-18977),
  71. array("diao",-18961),
  72. array("die",-18952),
  73. array("ding",-18783),
  74. array("diu",-18774),
  75. array("dong",-18773),
  76. array("dou",-18763),
  77. array("du",-18756),
  78. array("duan",-18741),
  79. array("dui",-18735),
  80. array("dun",-18731),
  81. array("duo",-18722),
  82. array("e",-18710),
  83. array("en",-18697),
  84. array("er",-18696),
  85. array("fa",-18526),
  86. array("fan",-18518),
  87. array("fang",-18501),
  88. array("fei",-18490),
  89. array("fen",-18478),
  90. array("feng",-18463),
  91. array("fo",-18448),
  92. array("fou",-18447),
  93. array("fu",-18446),
  94. array("ga",-18239),
  95. array("gai",-18237),
  96. array("gan",-18231),
  97. array("gang",-18220),
  98. array("gao",-18211),
  99. array("ge",-18201),
  100. array("gei",-18184),
  101. array("gen",-18183),
  102. array("geng",-18181),
  103. array("gong",-18012),
  104. array("gou",-17997),
  105. array("gu",-17988),
  106. array("gua",-17970),
  107. array("guai",-17964),
  108. array("guan",-17961),
  109. array("guang",-17950),
  110. array("gui",-17947),
  111. array("gun",-17931),
  112. array("guo",-17928),
  113. array("ha",-17922),
  114. array("hai",-17759),
  115. array("han",-17752),
  116. array("hang",-17733),
  117. array("hao",-17730),
  118. array("he",-17721),
  119. array("hei",-17703),
  120. array("hen",-17701),
  121. array("heng",-17697),
  122. array("hong",-17692),
  123. array("hou",-17683),
  124. array("hu",-17676),
  125. array("hua",-17496),
  126. array("huai",-17487),
  127. array("huan",-17482),
  128. array("huang",-17468),
  129. array("hui",-17454),
  130. array("hun",-17433),
  131. array("huo",-17427),
  132. array("ji",-17417),
  133. array("jia",-17202),
  134. array("jian",-17185),
  135. array("jiang",-16983),
  136. array("jiao",-16970),
  137. array("jie",-16942),
  138. array("jin",-16915),
  139. array("jing",-16733),
  140. array("jiong",-16708),
  141. array("jiu",-16706),
  142. array("ju",-16689),
  143. array("juan",-16664),
  144. array("jue",-16657),
  145. array("jun",-16647),
  146. array("ka",-16474),
  147. array("kai",-16470),
  148. array("kan",-16465),
  149. array("kang",-16459),
  150. array("kao",-16452),
  151. array("ke",-16448),
  152. array("ken",-16433),
  153. array("keng",-16429),
  154. array("kong",-16427),
  155. array("kou",-16423),
  156. array("ku",-16419),
  157. array("kua",-16412),
  158. array("kuai",-16407),
  159. array("kuan",-16403),
  160. array("kuang",-16401),
  161. array("kui",-16393),
  162. array("kun",-16220),
  163. array("kuo",-16216),
  164. array("la",-16212),
  165. array("lai",-16205),
  166. array("lan",-16202),
  167. array("lang",-16187),
  168. array("lao",-16180),
  169. array("le",-16171),
  170. array("lei",-16169),
  171. array("leng",-16158),
  172. array("li",-16155),
  173. array("lia",-15959),
  174. array("lian",-15958),
  175. array("liang",-15944),
  176. array("liao",-15933),
  177. array("lie",-15920),
  178. array("lin",-15915),
  179. array("ling",-15903),
  180. array("liu",-15889),
  181. array("long",-15878),
  182. array("lou",-15707),
  183. array("lu",-15701),
  184. array("lv",-15681),
  185. array("luan",-15667),
  186. array("lue",-15661),
  187. array("lun",-15659),
  188. array("luo",-15652),
  189. array("ma",-15640),
  190. array("mai",-15631),
  191. array("man",-15625),
  192. array("mang",-15454),
  193. array("mao",-15448),
  194. array("me",-15436),
  195. array("mei",-15435),
  196. array("men",-15419),
  197. array("meng",-15416),
  198. array("mi",-15408),
  199. array("mian",-15394),
  200. array("miao",-15385),
  201. array("mie",-15377),
  202. array("min",-15375),
  203. array("ming",-15369),
  204. array("miu",-15363),
  205. array("mo",-15362),
  206. array("mou",-15183),
  207. array("mu",-15180),
  208. array("na",-15165),
  209. array("nai",-15158),
  210. array("nan",-15153),
  211. array("nang",-15150),
  212. array("nao",-15149),
  213. array("ne",-15144),
  214. array("nei",-15143),
  215. array("nen",-15141),
  216. array("neng",-15140),
  217. array("ni",-15139),
  218. array("nian",-15128),
  219. array("niang",-15121),
  220. array("niao",-15119),
  221. array("nie",-15117),
  222. array("nin",-15110),
  223. array("ning",-15109),
  224. array("niu",-14941),
  225. array("nong",-14937),
  226. array("nu",-14933),
  227. array("nv",-14930),
  228. array("nuan",-14929),
  229. array("nue",-14928),
  230. array("nuo",-14926),
  231. array("o",-14922),
  232. array("ou",-14921),
  233. array("pa",-14914),
  234. array("pai",-14908),
  235. array("pan",-14902),
  236. array("pang",-14894),
  237. array("pao",-14889),
  238. array("pei",-14882),
  239. array("pen",-14873),
  240. array("peng",-14871),
  241. array("pi",-14857),
  242. array("pian",-14678),
  243. array("piao",-14674),
  244. array("pie",-14670),
  245. array("pin",-14668),
  246. array("ping",-14663),
  247. array("po",-14654),
  248. array("pu",-14645),
  249. array("qi",-14630),
  250. array("qia",-14594),
  251. array("qian",-14429),
  252. array("qiang",-14407),
  253. array("qiao",-14399),
  254. array("qie",-14384),
  255. array("qin",-14379),
  256. array("qing",-14368),
  257. array("qiong",-14355),
  258. array("qiu",-14353),
  259. array("qu",-14345),
  260. array("quan",-14170),
  261. array("que",-14159),
  262. array("qun",-14151),
  263. array("ran",-14149),
  264. array("rang",-14145),
  265. array("rao",-14140),
  266. array("re",-14137),
  267. array("ren",-14135),
  268. array("reng",-14125),
  269. array("ri",-14123),
  270. array("rong",-14122),
  271. array("rou",-14112),
  272. array("ru",-14109),
  273. array("ruan",-14099),
  274. array("rui",-14097),
  275. array("run",-14094),
  276. array("ruo",-14092),
  277. array("sa",-14090),
  278. array("sai",-14087),
  279. array("san",-14083),
  280. array("sang",-13917),
  281. array("sao",-13914),
  282. array("se",-13910),
  283. array("sen",-13907),
  284. array("seng",-13906),
  285. array("sha",-13905),
  286. array("shai",-13896),
  287. array("shan",-13894),
  288. array("shang",-13878),
  289. array("shao",-13870),
  290. array("she",-13859),
  291. array("shen",-13847),
  292. array("sheng",-13831),
  293. array("shi",-13658),
  294. array("shou",-13611),
  295. array("shu",-13601),
  296. array("shua",-13406),
  297. array("shuai",-13404),
  298. array("shuan",-13400),
  299. array("shuang",-13398),
  300. array("shui",-13395),
  301. array("shun",-13391),
  302. array("shuo",-13387),
  303. array("si",-13383),
  304. array("song",-13367),
  305. array("sou",-13359),
  306. array("su",-13356),
  307. array("suan",-13343),
  308. array("sui",-13340),
  309. array("sun",-13329),
  310. array("suo",-13326),
  311. array("ta",-13318),
  312. array("tai",-13147),
  313. array("tan",-13138),
  314. array("tang",-13120),
  315. array("tao",-13107),
  316. array("te",-13096),
  317. array("teng",-13095),
  318. array("ti",-13091),
  319. array("tian",-13076),
  320. array("tiao",-13068),
  321. array("tie",-13063),
  322. array("ting",-13060),
  323. array("tong",-12888),
  324. array("tou",-12875),
  325. array("tu",-12871),
  326. array("tuan",-12860),
  327. array("tui",-12858),
  328. array("tun",-12852),
  329. array("tuo",-12849),
  330. array("wa",-12838),
  331. array("wai",-12831),
  332. array("wan",-12829),
  333. array("wang",-12812),
  334. array("wei",-12802),
  335. array("wen",-12607),
  336. array("weng",-12597),
  337. array("wo",-12594),
  338. array("wu",-12585),
  339. array("xi",-12556),
  340. array("xia",-12359),
  341. array("xian",-12346),
  342. array("xiang",-12320),
  343. array("xiao",-12300),
  344. array("xie",-12120),
  345. array("xin",-12099),
  346. array("xing",-12089),
  347. array("xiong",-12074),
  348. array("xiu",-12067),
  349. array("xu",-12058),
  350. array("xuan",-12039),
  351. array("xue",-11867),
  352. array("xun",-11861),
  353. array("ya",-11847),
  354. array("yan",-11831),
  355. array("yang",-11798),
  356. array("yao",-11781),
  357. array("ye",-11604),
  358. array("yi",-11589),
  359. array("yin",-11536),
  360. array("ying",-11358),
  361. array("yo",-11340),
  362. array("yong",-11339),
  363. array("you",-11324),
  364. array("yu",-11303),
  365. array("yuan",-11097),
  366. array("yue",-11077),
  367. array("yun",-11067),
  368. array("za",-11055),
  369. array("zai",-11052),
  370. array("zan",-11045),
  371. array("zang",-11041),
  372. array("zao",-11038),
  373. array("ze",-11024),
  374. array("zei",-11020),
  375. array("zen",-11019),
  376. array("zeng",-11018),
  377. array("zha",-11014),
  378. array("zhai",-10838),
  379. array("zhan",-10832),
  380. array("zhang",-10815),
  381. array("zhao",-10800),
  382. array("zhe",-10790),
  383. array("zhen",-10780),
  384. array("zheng",-10764),
  385. array("zhi",-10587),
  386. array("zhong",-10544),
  387. array("zhou",-10533),
  388. array("zhu",-10519),
  389. array("zhua",-10331),
  390. array("zhuai",-10329),
  391. array("zhuan",-10328),
  392. array("zhuang",-10322),
  393. array("zhui",-10315),
  394. array("zhun",-10309),
  395. array("zhuo",-10307),
  396. array("zi",-10296),
  397. array("zong",-10281),
  398. array("zou",-10274),
  399. array("zu",-10270),
  400. array("zuan",-10262),
  401. array("zui",-10260),
  402. array("zun",-10256),
  403. array("zuo",-10254)
  404. );
  405. }
  406. function pingyin_lib()
  407. {
  408. $this->__construct();
  409. }
  410. function g($num)
  411. {
  412. $d = $this->pingying_d;
  413. if($num>0&&$num<160)
  414. {
  415. return chr($num);
  416. }
  417. elseif($num<-20319||$num>-10247)
  418. {
  419. return "";
  420. }
  421. else
  422. {
  423. for($i=count($d)-1;$i>=0;$i--)
  424. {
  425. if($d[$i][1]<=$num) break;
  426. }
  427. return $d[$i][0];
  428. }
  429. }
  430. function c($str)
  431. {
  432. $ret="";
  433. for($i=0;$i<strlen($str);$i++)
  434. {
  435. $p=ord(substr($str,$i,1));
  436. if($p>160)
  437. {
  438. $q=ord(substr($str,++$i,1));
  439. $p=$p*256+$q-65536;
  440. }
  441. $ret.=$this->g($p);
  442. }
  443. return $ret;
  444. }
  445. }
  446. ?>