手机
当前位置:查字典教程网 >编程开发 >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到正常文本】相关文章:

第十二节 类的自动加载 [12]

国内php原创论坛

第二节 对象模型 [2]

PHP 和 MySQL 基础教程(一)

使用Apache的rewrite技术

搭建基于Docker的PHP开发环境的详细教程

PHP自动更新新闻DIY

转换中文日期的PHP程序

层叠菜单的动态生成

在PHP中利用XML技术构造远程服务(上)

精品推荐
分类导航