網(wǎng)站設(shè)計(jì)師們?cè)谠O(shè)計(jì)上是否遇到了需要運(yùn)用asp base64編碼中文情況呢?創(chuàng)新互聯(lián)小編在網(wǎng)上找了很久,終于找到一個(gè)可以用的!現(xiàn)在分享給大家吧!
<%
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
%>
如果你在網(wǎng)站制作上遇到什么難題,歡迎咨詢成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè),我們專業(yè)從事網(wǎng)站建設(shè),網(wǎng)頁(yè)制作,域名注冊(cè),虛擬主機(jī),企業(yè)郵局,網(wǎng)站備案和服務(wù)器租用等項(xiàng)目,歡迎您的咨詢了解。您也可以登錄我們的論壇(http://bbs.cdxwcx.com)來(lái)和更多的網(wǎng)站愛好者進(jìn)行交流!