转换中文为unicode 转换unicode到正常文本
2007-06-08 13:45
351 查看
'//转换中文为unicode
function URLEncoding(vstrIn)
dim i
dim strReturn,ThisChr,innerCode,Hight8,Low8
strReturn = ""
for i = 1 to Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF then
strReturn = strReturn & ThisChr
else
innerCode = Asc(ThisChr)
If innerCode < 0 then
innerCode = innerCode + &H10000
end If
Hight8 = (innerCode and &HFF00)/ &HFF
Low8 = innerCode and &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
end If
next
URLEncoding = strReturn
end function
'//转换unicode到正常文本
function bytes2BSTR(vIn)
dim i
dim strReturn,ThisCharCode,nextCharCode
strReturn = ""
for i = 1 to LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 then
strReturn = strReturn & Chr(ThisCharCode)
else
nextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(nextCharCode))
i = i + 1
end If
next
bytes2BSTR = strReturn
end function
function getText(o,url)
dim oReq
on error resume next
if o is nothing then
'//创建XMLHTTP对象
set oReq = CreateObject("MSXML2.XMLHTTP")
else
set oReq = o
end if
oReq.open "get",url,false
oReq.send
if oReq.status = 200 or oReq.status = 0 then
getText = bytes2BSTR(oReq.responseBody)
else
getText = ""
end if
end function
function URLEncoding(vstrIn)
dim i
dim strReturn,ThisChr,innerCode,Hight8,Low8
strReturn = ""
for i = 1 to Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF then
strReturn = strReturn & ThisChr
else
innerCode = Asc(ThisChr)
If innerCode < 0 then
innerCode = innerCode + &H10000
end If
Hight8 = (innerCode and &HFF00)/ &HFF
Low8 = innerCode and &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
end If
next
URLEncoding = strReturn
end function
'//转换unicode到正常文本
function bytes2BSTR(vIn)
dim i
dim strReturn,ThisCharCode,nextCharCode
strReturn = ""
for i = 1 to LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 then
strReturn = strReturn & Chr(ThisCharCode)
else
nextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(nextCharCode))
i = i + 1
end If
next
bytes2BSTR = strReturn
end function
function getText(o,url)
dim oReq
on error resume next
if o is nothing then
'//创建XMLHTTP对象
set oReq = CreateObject("MSXML2.XMLHTTP")
else
set oReq = o
end if
oReq.open "get",url,false
oReq.send
if oReq.status = 200 or oReq.status = 0 then
getText = bytes2BSTR(oReq.responseBody)
else
getText = ""
end if
end function
相关文章推荐
- 转换中文为unicode 转换unicode到正常文本
- 转换中文为unicode 转换unicode到正常文本
- 转换中文为unicode 转换unicode到正常文本
- 转换中文为unicode 转换unicode到正常文本
- 本地win7 把数组写入 txt 文本日志 json_encode转换中文,需要加上JSON_UNESCAPED_UNICODE 不适用unicode --仅仅支持php5.4以后
- Unicode 转换成 Ascii (把Unicode 中文字符串输入到文本中)
- Python:如何将文本里的字典里的unicode字符转换成中文
- Unicode 转换成 Ascii (把Unicode 中文字符串输入到文本中)
- python unicode转中文及转换默认编码
- 解决php函数json_encode转换后中文被编码为unicode
- Unicode 编码中文 + 未编码中文符号 转换成UTF-8 中文 python实现
- idea中properties文件中文自动转换成unicode解决
- pl/sql developer窗口里面正常显示中文,复制,粘贴到文本文档出现乱码问题
- 采用native2ascii工具将中文字符的资源文件转换为Unicode代码格式的文件
- 随便发发,java gb2312与中文字符转换,以及中文和Unicode的转换
- Delphi unicode 数字转换成中文显示
- Python2如何将列表list的中文unicode转换为中文输出
- 使用Java将中文字符转换成Unicode编码
- 关于java UTF-8中文与Unicode编码之间转换,以及将浏览器地址栏编码过的中文转换UTF-8形式
- C#中文和UNICODE字符转换方法