当前位置: 移动技术网 > IT编程>开发语言>.net > asp base64编码中文

asp base64编码中文

2018年09月30日  | 移动技术网IT编程  | 我要评论

喝女王尿,伤感英文歌曲,伯恩尼

在网上找了很久,终于找到一个可以用的!
 
<%
 
 
 
function base64encode(sstring)
 
    if sstring = "" or isnull(sstring) then
 
        base64encode = ""
 
        exit function
 
    end if
 
    dim xml_dom, node
 
    set xml_dom = createobject("microsoft.xmldom")
 
 
 
    with xml_dom
 
        .loadxml ("<?xml version='1.0' ?> <root/>")
 
        set node = xml_dom.createelement("mytext")
 
        with node
 
            .datatype = "bin.base64"
 
            .nodetypedvalue = gb2312_stream(sstring)
 
            base64encode = .text
 
        end with
 
        xml_dom.documentelement.appendchild node
 
    end with
 
    set xml_dom = nothing
 
end function
 
 
 
function base64uncode(sstring)
 
    if sstring = "" or isnull(sstring) then
 
        base64uncode = ""
 
        exit function
 
    end if
 
    dim xml_dom, node
 
    set xml_dom = createobject("microsoft.xmldom")
 
    with xml_dom
 
        .loadxml ("<?xml version='1.0' ?> <root/>")
 
        set node = xml_dom.createelement("mytext")
 
        with node
 
            .datatype = "bin.base64"
 
            .text = sstring
 
            base64uncode = stream_gb2312(.nodetypedvalue)
 
        end with
 
        xml_dom.documentelement.appendchild node
 
    end with
 
    set xml_dom = nothing
 
end function
 
 
 
function gb2312_stream(sstring)
 
 
 
    dim dr
 
    set dr = createobject("adodb.stream")
 
    with dr
 
        .mode = 3
 
        .type = 2
 
        .open
 
        .charset = "gb2312"
 
        .writetext sstring
 
        .position = 0
 
        .type = 1
 
        gb2312_stream = .read
 
        .close
 
    end with
 
    set dr = nothing www.2cto.com
 
end function
 
 
 
function stream_gb2312(sstream)
 
    dim dr
 
    set dr = createobject("adodb.stream")
 
    with dr
 
        .mode = 3
 
        .type = 1
 
        .open
 
        .write sstream
 
        .position = 0
 
        .type = 2
 
        .charset = "gb2312"
 
        stream_gb2312 = .readtext
 
        .close
 
    end with
 
    set dr = nothing
 
end function
 
%>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网