网站设计师们在设计上是否遇到了需要运用asp base64编码中文情况呢?创新互联小编在网上找了很久,终于找到一个可以用的!现在分享给大家吧!
<%
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
%>
如果你在网站制作上遇到什么难题,欢迎咨询成都创新互联网站建设,我们专业从事网站建设,网页制作,域名注册,虚拟主机,企业邮局,网站备案和服务器租用等项目,欢迎您的咨询了解。您也可以登录我们的论坛(http://bbs.cdxwcx.com)来和更多的网站爱好者进行交流!