手机
当前位置:查字典教程网 >编程开发 >php教程 >转换中文为unicode 转换unicode到正常文本
转换中文为unicode 转换unicode到正常文本
摘要:复制代码代码如下:'//转换中文为unicodefunctionURLEncoding(vstrIn)dimidimstrReturn,Th...

复制代码 代码如下:

'//转换中文为unicode

functionURLEncoding(vstrIn)

dimi

dimstrReturn,ThisChr,innerCode,Hight8,Low8

strReturn=""

fori=1toLen(vstrIn)

ThisChr=Mid(vStrIn,i,1)

IfAbs(Asc(ThisChr))<&HFFthen

strReturn=strReturn&ThisChr

else

innerCode=Asc(ThisChr)

IfinnerCode<0then

innerCode=innerCode+&H10000

endIf

Hight8=(innerCodeand&HFF00)&HFF

Low8=innerCodeand&HFF

strReturn=strReturn&"%"&Hex(Hight8)&"%"&Hex(Low8)

endIf

next

URLEncoding=strReturn

endfunction

'//转换unicode到正常文本

functionbytes2BSTR(vIn)

dimi

dimstrReturn,ThisCharCode,nextCharCode

strReturn=""

fori=1toLenB(vIn)

ThisCharCode=AscB(MidB(vIn,i,1))

IfThisCharCode<&H80then

strReturn=strReturn&Chr(ThisCharCode)

else

nextCharCode=AscB(MidB(vIn,i+1,1))

strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(nextCharCode))

i=i+1

endIf

next

bytes2BSTR=strReturn

endfunction

functiongetText(oReq,url)

onerrorresumenext

'//创建XMLHTTP对象

ifoReqisnothingthen

setoReq=CreateObject("MSXML2.XMLHTTP")

endif

ifnotoReqisnothingthen

oReq.open"get",url,false

oReq.send

ifoReq.status=200then

getText=bytes2BSTR(oReq.responseBody)

else

getText=""

endif

else

getText=""

endif

endfunction

【转换中文为unicode 转换unicode到正常文本】相关文章:

php通过curl模拟登陆DZ论坛

使用Apache的rewrite技术

用PHP实现标准的IP Whois查询

PHP SPL标准库之接口(Interface)详解

PHP开发的9条经验总结

PHP自动更新新闻DIY

理解 PHP 中的 Streams

使用php的swoole实现高效安全的ftp服务器

php分别做为cgi和module来运行的配置

PHP SPL标准库之数据结构栈(SplStack)介绍

精品推荐
分类导航