Ec (2); classcntopy {& nbsp; ** & nbsp; * @ vararray $ chineseSpellList ing table & nbsp; * @ accessprivate & nbsp; * & nbsp; private $ chineseSpellListarray (& nbsp; a & gt;-2 script ec (2); script
Conversion of Chinese characters to PinYin
Class cntopy {
/**
* @ Var array $ chineseSpellList pinyin encoding table
* @ Access private
*/
Private $ chineseSpellList = array (
& Apos; a & apos; = & apos;-20319 & apos,
'Ai' =>-20317,
'Any' =>-20304,
'Ang '=>-20295,
'Ao' =>-20292,
'Ba' =>-20283,
'Ba' =>-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,
'Chunao' =>-19540,
'Ch' =>-19531,
'Chen' =>-19525,
'Hangzhou' =>-19515,
'Chi '=>-19500,
'Chong' =>-19484,
'Chou' =>-19479,
'Chu' =>-19467,
'Chuai' =>-19289,
'Chuanc' =>-19288,
'Shanghai' =>-19281,
'Chuis '=>-19275,
'Chun' =>-19270,
'Chuo' =>-19263,
'Cies' =>-19261,
'Cong' =>-19249,
'Cou' =>-19243,
'Cu '=>-19242,
'Cuance' =>-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,
'Duany' =>-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,
'Gal' =>-18239,
'Gai' =>-18237,
'Gan '=>-18231,
'Shanghai' =>-18220,
'Gao' =>-18211,
'Ge' =>-18201,
'Gei' =>-18184,
'Gen' =>-18183,
'Geng' =>-18181,
'Gong' =>-18012,
'Gou' =>-17997,
'GU' =>-17988,
'Gua' =>-17970,
'Guai' =>-17964,
'Guany' =>-17961,
'Guang '=>-17950,
'GU' =>-17947,
'Gun' =>-17931,
'Guo' =>-17928,
'Ha '=>-17922,
'Hai '=>-17759,
'Han' =>-17752,
'Hang' =>-17733,
'Hao' =>-17730,
'Hes' =>-17721,
'Hei' =>-17703,
'Hangzhou' =>-17701,
'Hangzhou' =>-17697,
'Hong '=>-17692,
'Hou' =>-17683,
'Hu' =>-17676,
'Hua' =>-17496,
'Huai' =>-17487,
'Huany' =>-17482,
'Huangt' =>-17468,
'Hui' =>-17454,
'Hun' =>-17433,
'Huo' =>-17427,
'Ji '=>-17417,
'Ja' =>-17202,
'Jian '=>-17185,
'Jiang '=>-16983,
'Shao' =>-16970,
'Jie' =>-16942,
'Jin' =>-16915,
'Jing' =>-16733,
'Jiong' =>-16708,
'Jiu' =>-16706,
'Ju' =>-16689,
'Juany' =>-16664,
'Jue '=>-16657,
'Jun' =>-16647,
'Ka '=>-16474,
'Kai' =>-16470,
'Kan '=>-16465,
'Hang' =>-16459,
'Kakao' =>-16452,
'Ke' =>-16448,
'Ken' =>-16433,
'Keng' =>-16429,
'Kong' =>-16427,
'Kou' =>-16423,
'Ku '=>-16419,
'Kua' =>-16412,
'Kuai' =>-16407,
'Kuany' =>-16403,
'Kuang '=>-16401,
'Kuai' =>-16393,
'Non' =>-16220,
'Kuo' =>-16216,
'La '=>-16212,
'Les' =>-16205,
'Lan' =>-16202,
'Lang '=>-16187,
'Lao' =>-16180,
'Le' =>-16171,
'Lei' =>-16169,
'Leng' =>-16158,
'Lil' =>-16155,
'Lia '=>-15959,
'Liany' =>-15958,
'Shanghai' =>-15944,
'Liao' =>-15933,
'Lil' =>-15920,
'Lin' =>-15915,
'Ling' =>-15903,
'Liu '=>-15889,
'Long' =>-15878,
'Loud' =>-15707,
'Rou' =>-15701,
'Lv' =>-15681,
'Luand' =>-15667,
'Lue' =>-15661,
'Luns '=>-15659,
'Luo' =>-15652,
'Ma' =>-15640,
'Mai' =>-15631,
'Man' =>-15625,
'Mang' =>-15454,
'Mao '=>-15448,
'Me' =>-15436,
'Mei' =>-15435,
'Men' =>-15419,
'Meng' =>-15416,
'Mi' =>-15408,
'Miany' =>-15394,
'Miao' =>-15385,
'Mie '=>-15377,
'Min' =>-15375,
'Ming' =>-15369,
'Miu' =>-15363,
'Mo' =>-15362,
'Mou' =>-15183,
'Mu '=>-15180,
'A' =>-15165,
'Nai' =>-15158,
'Nan '=>-15153,
'Nang '=>-15150,
'Nao' =>-15149,
'Ne '=>-15144,
'Nei' =>-15143,
'Nen' =>-15141,
'Neng' =>-15140,
'Ni' =>-15139,
'Niany' =>-15128,
'Niang '=>-15121,
'Niao' =>-15119,
'Ni' =>-15117,
'Nin' =>-15110,
'Ning' =>-15109,
'Niu' =>-14941,
'Nong' =>-14937,
'Nu '=>-14933,
'Nv '=>-14930,
'Nuany' =>-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,
'Piany' =>-14678,
'Piao' =>-14674,
'Pie' =>-14670,
'Pin' =>-14668,
'Ping' =>-14663,
'Po' =>-14654,
'Put' =>-14645,
'Qy' =>-14630,
'Qia '=>-14594,
'Qian '=>-14429,
'Qiang '=>-14407,
'Qiao' =>-14399,
'Qie' =>-14384,
'Qin' =>-14379,
'Qing' =>-14368,
'Qiong' =>-14355,
'Qiu '=>-14353,
'Qu' =>-14345,
'Quanc' =>-14170,
'Que '=>-14159,
'Qun' =>-14151,
'Run' =>-14149,
'Rang '=>-14145,
'Rao' =>-14140,
'Re' =>-14137,
'Ren' =>-14135,
'Reng' =>-14125,
'Ri' =>-14123,
'Rong '=>-14122,
'Rou' =>-14112,
'Ru '=>-14109,
'Rule' =>-14099,
'Rui '=>-14097,
'Run' =>-14094,
'Ruo' =>-14092,
'Sa '=>-14090,
'Sai '=>-14087,
'San' =>-14083,
'Shanghai' =>-13917,
'Sao' =>-13914,
'Se' =>-13910,
'Sen' =>-13907,
'Seng' =>-13906,
'Sha' =>-13905,
'Shai' =>-13896,
'Shanc' =>-13894,
'Shang '=>-13878,
'Shao' =>-13870,
'She' =>-13859,
'Shen' =>-13847,
'Sheng' =>-13831,
'Shi '=>-13658,
'Shou' =>-13611,
'Shu' =>-13601,
'Shua '=>-13406,
'Shuai' =>-13404,
'Shuany' =>-13400,
'Shuang '=>-13398,
'Shuis '=>-13395,
'Shanghai' =>-13391,
'Shuo '=>-13387,
'Si' =>-13383,
'Png' =>-13367,
'Sou' =>-13359,
'Su' =>-13356,
'Suance' =>-13343,
'Sui' =>-13340,
'Sun' =>-13329,
'Suo' =>-13326,
'Ta' =>-13318,
'Tai' =>-13147,
'Tan' =>-13138,
'Shanghai' =>-13120,
'Tao' =>-13107,
'Te' =>-13096,
'Teng' =>-13095,
'Ti' =>-13091,
'Tiany' =>-13076,
'Tiao' =>-13068,
'Tie '=>-13063,
'Ting' =>-13060,
'Tongg' =>-12888,
'Tou' =>-12875,
'Tu' =>-12871,
'Tuany' =>-12860,
'Tui '=>-12858,
'Tun '=>-12852,
& Apos; tuo' = & apos;-12849 & apos,
'Wa '=>-12838,
'Wai' =>-12831,
'Wan '=>-12829,
'Wang' =>-12812,
'Wei' =>-12802,
'Wen' =>-12607,
'Engg' =>-12597,
'Wo' =>-12594,
'Wu' =>-12585,
'Si' =>-12556,
'CIA' =>-12359,
'Xian '=>-12346,
'Shanghai' =>-12320,
'Xiao' =>-12300,
'Xie' =>-12120,
'Sin' =>-12099,
'X' =>-12089,
'Xiong' =>-12074,
'Xiu' =>-12067,
'Xu '=>-12058,
'Xuany' =>-12039,
'Xue '=>-11867,
'Xun' =>-11861,
'Ya' =>-11847,
'Any' =>-11831,
'Yang' =>-11798,
'Yunao' =>-11781,
'Ye '=>-11604,
'Yi' =>-11589,
'Yin' =>-11536,
'Ying' =>-11358,
'Yo' =>-11340,
'Yong' =>-11339,
'You' =>-11324,
'Yu '=>-11303,
'Yuanyuan '=>-11097,
'Yue' =>-11077,
'Yun '=>-11067,
'Za' =>-11055,
'Zai' =>-11052,
'Zany' =>-11045,
'Zang '=>-11041,
'Zao' =>-11038,
'Z' =>-11024,
'Zei' =>-11020,
'Zn' =>-11019,
'Zeng' =>-11018,
'Zha' =>-11014,
'Zhai' =>-10838,
'Zhan' =>-10832,
'Zhang '=>-10815,
'Zhao' =>-10800,
'Zhes' =>-10790,
'Zhen' =>-10780,
'Zheng' =>-10764,
'Zhi' =>-10587,
'Zhong' =>-10544,
'Zhou' =>-10533,
'Zhu' =>-10519,
'Zhua' =>-10331,
'Zhuai' =>-10329,
'Zhuanc' =>-10328,
'Zhuang '=>-10322,
'Zhui' =>-10315,
'Zhun' =>-10309,
'Zhuo' =>-10307,
'Zi' =>-10296,
'Zong' =>-10281,
'Zou' =>-10274,
'Zu' =>-10270,
'Zuan' =>-10262,
'Zui '=>-10260,
'Zun '=>-10256,
& Apos; zuo' = & apos;-10254
);
/**
* Retrieve all Chinese Characters in pinyin
* @ Param string $ chinese characters to be converted
* @ Param string $ delimiter Separator
* @ Param int $ length returns the length
* @ Return string
*/
Public function getFullSpell ($ chinese, $ delimiter = '', $ length =
0 ){
$ Spell = $ this-> getChineseSpells ($ chinese, $ delimiter );
If ($ length ){
$ Spell = substr ($ spell, 0, $ length );
}
Return $ spell;
}
/**
* Obtain the first Chinese pinyin.
* @ Param string $ chinese characters to be converted
* @ Param int $ length returns the length
* @ Return string
*/
Public function getFirstSpell ($ chinese, $ length = 0 ){
$ Spell = $ this-> getChineseSpells ($ chinese, '', 1 );
If ($ length ){
$ Spell = substr ($ spell, 0, $ length );
}
Return $ spell;
}
/**
* Obtain the pinyin corresponding to a Chinese character code.
* @ Param int $ num Chinese character code
* @ Param string $ blank characters
* @ Return string
*/
Private function getChineseSpell ($ num, $ blank = ''){
If ($ num> 0 & $ num <160 ){
Return chr ($ num );
} Elseif ($ num <-20319 | $ num>-10247 ){
Return $ blank;
} Else {
Foreach ($ this-> chineseSpellList as $ spell => $ code)
{
If ($ code> $ num) break;
$ Result = $ spell;
}
Return $ result;
}
}
/**
* Chinese pinyin
* @ Param string $ chinese characters to be converted
* @ Param string $ delimiter Separator
* @ Param int $ first: whether to return only the first one
* @ Return string
*/
Private function getChineseSpells ($ chinese, $ delimiter = '',
$ First = 0)
{
$ Result = array ();
For ($ I = 0; $ I $ P = ord (substr ($ chinese, $ I, 1 ));
If ($ p & gt; 160 ){
$ Q = ord (substr ($ chinese, ++ $ I, 1 ));
$ P = $ p * 256 + $ q-65536;
}
$ Result [] = $ this-> getChineseSpell ($ p );
If ($ first ){
Return $ result [0];
}
}
Return implode ($ delimiter, $ result );
}
}