UTF-8编码第1/2页

2019-01-14 08:41:59丽君

else
{
x++;
wch1 = parseInt(szInput.charAt(++x) + szInput.charAt(++x),16);
x++;
wch2 = parseInt(szInput.charAt(++x) + szInput.charAt(++x),16);
wch = (wch & 0x0F)<< 12;
wch1 = (wch1 & 0x3F)<< 6;
wch2 = (wch2 & 0x3F);
wch = wch + wch1 + wch2;
}
szRet += String.fromCharCode(wch);
}
else
{
szRet += szInput.charAt(x);
}
}
return(szRet);
}



function u2utf8($c) 

/*for($i=0;$i<count($c);$i++)*/ 
$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; 
}
12下一页阅读全文

您可能感兴趣的文章:

utf-8编码引起js输出中文乱码的解决办法php中utf-8编码下用正则表达式如何匹配汉字解决IE不能主动识别UTF-8编码的问题的方法ASP生成UTF-8编码的代码UTF-8编码问题BOM详细介绍utf-8编码技巧 url编码问题utf-8编码转换成gb2312修改mysql5.5默认编码(图文步骤修改为utf-8编码)