转换中文为unicode 转换unicode到正常文本_php教程-查字典教程网
转换中文为unicode 转换unicode到正常文本
转换中文为unicode 转换unicode到正常文本
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:'//转换中文为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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类