asp中文编码和php编码的区别,asp(vbs),php,解码&#;utf8编码

str0= "这是一个utf-8字符串! "

function   reg_arr(reg_str,str,ml)

Set   re   =   New   RegExp

re.Pattern   =   reg_str

re.Global   =   True

re.IgnoreCase   =   True

re.MultiLine   =   True

set   m=re.execute(str)

dim   rtn

dim   tmp

redim   rtn(m.count-1)

i=0

for   each   mt   in   m

mv=mt.value

redim   tmp(ml)

for   k=1   to   ml

par= "$ "&k

tmp(k-1)=re.replace(mv,par)

next

rtn(i)=tmp

i=i+1

next

reg_arr=rtn

end   function

function   utf8code2gb(str)

strs=reg_arr( "(/d+); ",str,1)

for   i=0   to   ubound(strs)

str=replace(str, " "&strs(i)(0)& "; ",chrw(strs(i)(0)))

next

utf8code2gb=str

end   function

msgbox(utf8code2gb(str0))

%E6%8C%A8%E6%89%93用的是ascii编码的16进制

挨打是unicode编码

$str = "老大哥";

$str = preg_replace("|([0-9]{1,5});|", "/".u2utf82gb(//1)./"", $str);

$str = "/$str=/"$str/";";

eval($str);

echo $str;

function u2utf82gb($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 iconv('UTF-8', 'GB2312', $str);

}

?>

再加一个手册上的例子,解决:%u697C%u4E3B%u8111%u58F3%u53D1%u660F%u7528%u9519%u8BCD%u4E86%u5427%3F%20%0D%0A%u4F60%u53EF%u4EE5%u770B%u4E0D%u8D77%u9C81%u8FC5%2C%u4F46%u4F60%u4E0D%u53EF%u4EE5%u7528%u4ED6%u6765%u5F62%u5BB9%u8DD1

function unicode_urldecode($url)

{

preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);

foreach ($a[1] as $uniord)

{

$dec = hexdec($uniord);

$utf = '';

if ($dec < 128)

{

$utf = chr($dec);

}

else if ($dec < 2048)

{

$utf = chr(192 + (($dec - ($dec % 64)) / 64));

$utf .= chr(128 + ($dec % 64));

}

else

{

$utf = chr(224 + (($dec - ($dec % 4096)) / 4096));

$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));

$utf .= chr(128 + ($dec % 64));

}

$url = str_replace('%u'.$uniord, $utf, $url);

}

return urldecode($url);

}

群名称是: PHPer&页游&Mobile&U3D 2D

群号:95303036

加群除了提问之外,请记得帮助别人,谢谢。

----------------------------------再发个广告,网上买家具便宜1/4,还包邮。点图进入,支持下我老婆。0818b9ca8b590ca3270a3433284dd417.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值