function u2utf8($c) {
$str="";
if ($c < 0x80) {
$str=$c;
}else{
if ($c < 0x800) {
$str=chr(0xC0 | $c>>6);
$str=chr(0x80 | $c & 0x3F);
}else{
if ($c < 0x10000) {
$str.=chr(0xE0 | $c>>12);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
}else{
if($c < 0x200000){
$str.=chr(0xF0 | $c>>18);
$str.=chr(0x80 | $c>>12 & 0x3F);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
}
}
}
}
return $str;
}
echo mb_convert_encoding(u2utf8(27979),"GB2312","UTF-8");
输出"测"字,27979是"测"字的unicode十进制内码
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货