CopyCode The Code is as follows: <% @ Language = "VBScript" codePage = "65001" %>
<% Session. codePage = 65001%>
<! -- # Include file = "base64.asp" -->
<%
Function aspurldecode (strvalue)
Dim varary, varelement, objstream, lngloop, flag
Strvalue = Replace (strvalue, "+ ","")
Varary = Split (strvalue, "% ")
Flag = varary (0) = ""
Set objstream = server. Createobject ("ADODB. Stream ")
With objstream
. Type = 2
. Mode = 3
. Open
For each varelement in varary
If varelement <> empty then
If Len (varelement)> = 2 and flag then
. Writetext chrb (CINT ("& H" & left (varelement, 2 )))
For lngloop = 3 to Len (varelement)
. Writetext chrb (ASC (mid (varelement, lngloop, 1 )))
Next
Else
For lngloop = 1 to Len (varelement)
. Writetext chrb (ASC (mid (varelement, lngloop, 1 )))
Next
Flag = true
End if
End if
Next
. Writetext CHR (0)
. Position = 0
Aspurldecode = Replace (convunicode (. readtext), CHR (0), "", 1,-1, 0)
On Error resume next
. Close
Set objstream = nothing
End
End Function
function convunicode (byval strdata)
dim RS, STM, bytary, intlen
If Len (strdata & "")> 0 then
strdata = midb (strdata, 1)
intlen = lenb (strdata)
set rs = server. createobject ("ADODB. recordset ")
set STM = server. createobject ("ADODB. stream ")
with RS
. fields. append & quot; X & quot;, 205, intlen & quot;
. open
. addnew
RS (0 ). appendChunk strdata & chrb (0)
. update
bytary = RS (0 ). getchunk (intlen)
end with
with STM
. type = 1
. open
. write bytary
. position = 0
. type = 2
. charset = "UTF-8"
convunicode =. readtext
end with
end if
on error resume next
STM. close
set STM = nothing
Rs. close
set rs = nothing
end function
%>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
</Head>
<Body>
<%
'After base64 encoding, 77u/is more than. net/
Response. Write ("after base64 encoding:" & base64encode ("A Hui Nan") & "<br/> ")
'Base64 decoded
Response. Write ("base64 decoded:" & base64uncode ("6zi/5lya5qwg") & "<br/> ")
%>
</Body>
</Html>