asp base64编码中文
程序员文章站
2022-07-01 23:04:24
在网上找了很久,终于找到一个可以用的!
<%
function base64encode(sstring)
&...
在网上找了很久,终于找到一个可以用的!
<%
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
%>
<%
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
%>