ASP base64 UTF-8 to be compatible with Asp.net base64

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.