A large number of NOTIC errors occur when php retrieves and sorts the Chinese character initials. the function getFirstChar ($ str ){
If (empty ($ str )){
Return '';
}
$ Fchar = ord ($ str {0 });
If ($ fchar> = ord ('A') & $ fchar <= ord ('Z ')){
Return strtoupper ($ str {0 });
}
$ S1 = iconv ('utf-8', 'gb18030', $ str );
$ S2 = iconv ('gb18030', 'utf-8', $ s1 );
$ S = $ s2 = $ str? $ S1: $ str;
$ Asc = ord ($ s {0}) * 256 + ord ($ s {1})-65536;
If ($ asc >=- 20319 & $ asc <=-20284) return 'A ';
If ($ asc >=- 20283 & $ asc <=-19776) return 'B ';
If ($ asc >=- 19775 & $ asc <=-19219) return 'C ';
If ($ asc >=- 19218 & $ asc <=-18711) return 'd ';
If ($ asc >=- 18710 & $ asc <=-18527) return 'e ';
If ($ asc >=- 18526 & $ asc <=-18240) return 'F ';
If ($ asc >=- 18239 & $ asc <=-17923) return 'g ';
If ($ asc >=- 17922 & $ asc <=-17418) return 'h ';
If ($ asc >=- 17417 & $ asc <=-16475) return 'J ';
If ($ asc >=- 16474 & $ asc <=-16213) return 'K ';
If ($ asc >=- 16212 & $ asc <=-15641) return 'L ';
If ($ asc >=- 15640 & $ asc <=-15166) return 'M ';
If ($ asc >=- 15165 & $ asc <=-14923) return 'n ';
If ($ asc >=- 14922 & $ asc <=-14915) return 'O ';
If ($ asc >=- 14914 & $ asc <=-14631) return 'P ';
If ($ asc >=- 14630 & $ asc <=-14150) return 'q ';
If ($ asc >=- 14149 & $ asc <=-14091) return 'R ';
If ($ asc >=- 14090 & $ asc <=-13319) return's ';
If ($ asc >=- 13318 & $ asc <=-12839) return't ';
If ($ asc >=- 12838 & $ asc <=-12557) return 'w ';
If ($ asc >=- 12556 & $ asc <=-11848) return 'x ';
If ($ asc >=- 11847 & $ asc <=-11056) return 'y ';
If ($ asc >=- 11055 & $ asc <=-10247) return 'Z ';
Return null;
}
NOTIC: [8] iconv (): Detected an illegal character in input string D: \ develop \ upupw \ htdocs \ shixiapi \ App \ Common \ function. php row 1,157th.
NOTIC: [8] iconv (): Detected an illegal character in input string D: \ develop \ upupw \ htdocs \ shixiapi \ App \ Common \ function. php row 1,157th.
NOTIC: [8] iconv (): Detected an illegal character in input string D: \ develop \ upupw \ htdocs \ shixiapi \ App \ Common \ function. php row 1,157th.
Reply to discussion (solution)
Simply put
$s1 = @iconv('UTF-8', 'GB18030',$str);$s2 = @iconv('GB18030','UTF-8',$s1);
Rule point
$s = mb_check_encoding($str, 'utf-8') ? iconv('utf-8', 'gbk', $str) : $str;
Although the GB18030 standard has been released, it has not been implemented in any system