unicode 格式 转汉字
程序员文章站
2022-10-24 14:05:13
function decodeUnicode($str){ return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function( '$matches', 'return mb_convert_encoding(pack("H*" ......
function decodeunicode($str)
{
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
create_function(
'$matches',
'return mb_convert_encoding(pack("h*", $matches[1]), "utf-8", "ucs-2be");'
),
$str);
}
$arr = array('name1':"中文",'name2':'abc12');
$jsonstr = decodeunicode(json_encode($arr));