解决办法:
1、修改自己的名字为英文或者GB2312,一些脑残体会导致这种情况
2、修改转换代码改成如下:
function unicode_encode($str)
{
$str =iconv('UTF-8', 'UCS-2', $str);
$len = strlen($str);
$newstr = '';
for($i = 0; $i < $len - 1; $i = $i + 2)
{
$c = $str[$i];
$c2 = $str[$i+1];
if (ord($c) > 0)
{
//tow byte
$s = base_convert(ord($c), 10, 16);
if(hexdec($s) > 0xF)
$newstr .='\\u'.$s;
else
$newstr .='\\u'.'0'.$s;
$s = base_convert(ord($c2), 10, 16);
if(hexdec($s) > 0xF)
$newstr .=$s;
else
$newstr .='0'.$s;
}
elseif(ord($c2)<127)
{
$newstr .= $c2;
}
}
return $newstr;
}
function unicode_encodegb($str)
{
$str =iconv('GBK', 'UCS-2', $str);
$len = strlen($str);
$newstr = '';
for($i = 0; $i < $len - 1; $i = $i + 2)
{
$c = $str[$i];
$c2 = $str[$i+1];
if (ord($c) > 0)
{
//tow byte
$s = base_convert(ord($c), 10, 16);
if(hexdec($s) > 0xF)
$newstr .='\\u'.$s;
else
$newstr .='\\u'.'0'.$s;
$s = base_convert(ord($c2), 10, 16);
if(hexdec($s) > 0xF)
$newstr .=$s;
else
$newstr .='0'.$s;
}
elseif(ord($c2)<127)
{
$newstr .= $c2;
}
}
return $newstr;
}
function unicode_encodebig5($str)
{
$str =iconv('big5', 'UCS-2', $str);
$len = strlen($str);
$newstr = '';
for($i = 0; $i < $len - 1; $i = $i + 2)
{
$c = $str[$i];
$c2 = $str[$i+1];
if (ord($c) > 0)
{
//tow byte
$s = base_convert(ord($c), 10, 16);
if(hexdec($s) > 0xF)
$newstr .='\\u'.$s;
else
$newstr .='\\u'.'0'.$s;
$s = base_convert(ord($c2), 10, 16);
if(hexdec($s) > 0xF)
$newstr .=$s;
else
$newstr .='0'.$s;
}
elseif(ord($c2)<127)
{
$newstr .= $c2;
}
}
return $newstr;
}
那样就OK了!!! |