威凡网全力打造:网页编程、软件开发编程、平面设计、服务器端开发、操作系统等在线学习平台!学编程,上威凡网!
ASP教程>> ASP基础 应用技巧 数据库相关 ASP类 存储过程 FSO专栏 ASP其他
当前位置:首页 > ASP教程 > 应用技巧
上一节 下一节
 转换中文为unicode 转换unicode到正常文本

复制代码 代码如下:

'//转换中文为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


申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!
上一节 下一节
相关教程  
其他教程  
ASP基础
应用技巧
数据库相关
ASP类
存储过程
FSO专栏
ASP其他

违法和不良信息举报中心】邮箱:254677821@qq.com
Copyright©威凡网 版权所有 苏ICP备2023020142号
站长QQ:254677821