/**
* 將unicode轉化成中文
*
* @param [type] $match
* @return void
*/
function unicodeToChn($str){
// %u9280%u884C%u5132%u503C -> \u9280\u884C\u5132\u503C
//$str = str_replace('%u', '\u', $str);
//$pattern = '/\\\\u([0-9a-f]{4})/i';
$pattern = '/%u([0-9a-f]{4})/i'; //改用這個快不少
$result = preg_replace_callback($pattern, function($matches){
return iconv('UCS-2', 'UTF-8', hex2bin($matches[1]));
}, $str);
return $result;
}
phpunicode轉化為中文編碼
于 2023-07-25 15:54:33 首次发布