php 汉子转unicode编码输出

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;
}

你可能感兴趣的:(php 汉子转unicode编码输出)