echo (uni_encode('请');
function uni_encode ($word)
{
$word0 = iconv('gbk', 'utf-8', $word);
$word1 = iconv('utf-8', 'gbk', $word0);
$word = ($word1 == $word) ? $word0 : $word;
$word = json_encode($word);
$word = preg_replace_callback('/\\\\u(\w{4})/', create_function('$hex', 'return \'&#\'.hexdec($hex[1]).\';\';'), substr($word, 1, strlen($word)-2));
return $word;
}
function uni_encode ($word)
{
$word0 = iconv('gbk', 'utf-8', $word);
$word1 = iconv('utf-8', 'gbk', $word0);
$word = ($word1 == $word) ? $word0 : $word;
$word = json_encode($word);
$word = preg_replace_callback('/\\\\u(\w{4})/', create_function('$hex', 'return \'&#\'.hexdec($hex[1]).\';\';'), substr($word, 1, strlen($word)-2));
return $word;
}