ASP base64 utf-8 for compatible asp.net base64_ application techniques

Source: Internet
Author: User
Tags base64 chr
Copy Code code 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 (varelement, Lngloop, 1))
Next
Else
For lngloop = 1 to Len (varelement)
. WRITETEXT ChrB (ASC (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 With
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 "X", 205, Intlen
. 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 ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<body>
<%


' Base64 encoded, compared to. NET more 77u/
Response.Write ("Base64 Code:" &base64encode ("O ' Nan") & "<br/>")

' Base64 after decoding
Response.Write ("Base64 after decoding:" &base64uncode ("6ZI/5LYA5QWG") & "<br/>")

%>
</body>

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.