Function getfirstchar ($ S0 ){
$ Fchar = ord ($ S0 {0 });
If ($ fchar> = ord ("A") and $ fchar <= ord ("Z") return strtoupper ($ S0 {0 });
$ S1 = iconv ("UTF-8", "gb2312", $ S0 );
$ S2 = iconv ("gb2312", "UTF-8", $ S1 );
If ($ S2 = $ S0) {$ S = $ S1;} else {$ S = $ S0 ;}
$ ASC = ord ($ s {0}) * 256 + ord ($ s {1})-65536;
If ($ ASC >=- 20319 and $ ASC <=-20284) Return "";
If ($ ASC >=- 20283 and $ ASC <=-19776) Return "B ";
If ($ ASC >=- 19775 and $ ASC <=-19219) Return "C ";
If ($ ASC >=- 19218 and $ ASC <=-18711) Return "D ";
If ($ ASC >=- 18710 and $ ASC <=-18527) Return "E ";
If ($ ASC >=- 18526 and $ ASC <=-18240) Return "F ";
If ($ ASC >=- 18239 and $ ASC <=-17923) Return "G ";
If ($ ASC >=- 17922 and $ ASC <=-17418) Return "I ";
If ($ ASC >=- 17417 and $ ASC <=-16475) Return "J ";
If ($ ASC >=- 16474 and $ ASC <=-16213) Return "K ";
If ($ ASC >=- 16212 and $ ASC <=-15641) Return "L ";
If ($ ASC >=- 15640 and $ ASC <=-15166) Return "M ";
If ($ ASC >=- 15165 and $ ASC <=-14923) Return "N ";
If ($ ASC >=- 14922 and $ ASC <=-14915) Return "O ";
If ($ ASC >=- 14914 and $ ASC <=- 14631) Return "p ";
If ($ ASC >=- 14630 and $ ASC <=-14150) Return "Q ";
If ($ ASC >=- 14149 and $ ASC <=-14091) Return "R ";
If ($ ASC >=- 14090 and $ ASC <=-13319) Return "S ";
If ($ ASC >=- 13318 and $ ASC <=-12839) Return "T ";
If ($ ASC >=- 12838 and $ ASC <=-12557) Return "W ";
If ($ ASC >=- 12556 and $ ASC <=-11848) Return "X ";
If ($ ASC >=- 11847 and $ ASC <=-11056) Return "Y ";
If ($ ASC >=- 11055 and $ ASC <=- 10247) Return "Z ";
Return NULL;
}
Function pinyin1 ($ ZH)
{
$ Ret = "";
$ S1 = iconv ("UTF-8", "gb2312", $ ZH );
$ S2 = iconv ("gb2312", "UTF-8", $ S1 );
If ($ S2 = $ ZH) {$ ZH = $ S1 ;}
For ($ I = 0; $ I <strlen ($ ZH); $ I ++)
{
$ S1 = substr ($ ZH, $ I, 1 );
$ P = ord ($ S1 );
If ($ P> 160)
{
$ S2 = substr ($ ZH, $ I ++, 2 );
$ Ret. = getfirstchar ($ S2 );
}
Else
{
$ Ret. = $ S1;
}
}
Return $ ret;
}