zl程序教程

您现在的位置是:首页 >  后端

当前栏目

aspbase64utf-8为了兼容asp.net的base64

NetASP 兼容 为了 base64
2023-06-13 09:14:11 时间
复制代码代码如下:

<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>
<%Session.CodePage=65001%>
<!--#includefile="base64.asp"-->
<%
FunctionAspUrlDecode(strValue)
DimvarAry,varElement,objStream,lngLoop,Flag
strValue=Replace(strValue,"+","")
varAry=Split(strValue,"%")
Flag=varAry(0)=""
SetobjStream=Server.CreateObject("ADODB.Stream")
WithobjStream
.Type=2
.Mode=3
.Open
ForEachvarElementInvarAry
IfvarElement<>EmptyThen
IfLen(varElement)>=2AndFlagThen
.WriteTextChrB(CInt("&H"&Left(varElement,2)))
ForlngLoop=3ToLen(varElement)
.WriteTextChrB(Asc(Mid(varElement,lngLoop,1)))
Next
Else
ForlngLoop=1ToLen(varElement)
.WriteTextChrB(Asc(Mid(varElement,lngLoop,1)))
Next
Flag=True
EndIf
EndIf
Next
.WriteTextChr(0)
.Position=0
AspUrlDecode=Replace(ConvUnicode(.ReadText),Chr(0),"",1,-1,0)
OnErrorResumeNext
.Close
SetobjStream=Nothing
EndWith
EndFunction



FunctionConvUnicode(ByValstrData)
Dimrs,stm,bytAry,intLen
IfLen(strData&"")>0Then
strData=MidB(strData,1)
intLen=LenB(strData)
Setrs=Server.CreateObject("ADODB.Recordset")
Setstm=Server.CreateObject("ADODB.Stream")
Withrs
.Fields.Append"X",205,intLen
.Open
.AddNew
rs(0).AppendChunkstrData&ChrB(0)
.Update
bytAry=rs(0).GetChunk(intLen)
EndWith
Withstm
.Type=1
.Open
.WritebytAry
.Position=0
.Type=2
.Charset="utf-8"
ConvUnicode=.ReadText
EndWith
EndIf
OnErrorResumeNext
stm.Close
Setstm=Nothing
rs.Close
Setrs=Nothing
EndFunction


%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
</head>
<body>
<%


"base64编码后,比起.net多了77u/
Response.Write("base64编码后:"&base64Encode("阿会楠")&"<br/>")

"base64解码后
Response.Write("base64解码后:"&base64uncode("6Zi/5Lya5qWg")&"<br/>")

%>
</body>
</html>