输入banner图图片脚本导航/分类

UTF-8编码第1/2页

参考文档:http://www.gxlsystem.com/search?hl=zh-CN&newwindow=1&rls=GGLG%2CGGLG%3A2006-15%2CGGLG%3Azh-CN&q=你的编码
代码如下:
function revertUTF8(szInput)
{
var x,wch,wch1,wch2,uch="",szRet="";
for (x=0; x<szInput.length; x++)
{
if (szInput.charAt(x)=="%")
{
wch =parseInt(szInput.charAt(++x) + szInput.charAt(++x),16);
if (!wch) {break;}
if (!(wch & 0x80))
{
wch = wch;
}
else if (!(wch & 0x20))
{
x++;
wch1 = parseInt(szInput.charAt(++x) + szInput.charAt(++x),16);
wch = (wch & 0x1F)<< 6;
wch1 = wch1 & 0x3F;
wch = wch + wch1;
}
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下一页阅读全文