I encountered a decoding problem when developing with ASP. Although using Request to obtain encoded URL strings in ASP will automatically decode, Request.BinaryRead(Request.TotalBytes) will not decode when obtaining Post data, so you can only decode it manually.
ASP decoding function:
Function URLDecode(enStr) dim deStr,strSpecial dim c,i,v deStr="" strSpecial="!""#$%&'()*+,.-_/:;<=>?@[/]^`{|}~%" for i=1 to len(enStr) c=Mid(enStr,i,1) if c="%" then v=eval("&h"+Mid(enStr,i+1,2)) if inStr(strSpecial,chr(v))>0 then deStr=deStr&chr(v) i=i+2 else v=eval("&h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2)) deStr=deStr & chr(v) i=i+5 end if else if c="+" then deStr=deStr&" " else deStr=deStr&c end if end if next URLDecode=deStr End functionIt’s just a personal hobby. I studied the implementation ideas of coding by myself, and finally wrote an encoding function for your reference. Note: ASP has a built-in encoding function, namely Server.URLEncode.
ASP encoding function:
private Function URLEncoding(vstrIn) strReturn = "" For i = 1 To Len(vstrIn) ThisChr = Mid(vStrIn,i,1) If Abs(Asc(ThisChr)) < &HFF Then strReturn = strReturn & ThisChr Else innerCode = Asc(ThisChr) If innerCode < 0 Then innerCode = innerCode + &H10000 End If Hight8 = (innerCode And &HFF00)/ &HFF Low8 = innerCode And &HFF strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8) End If Next URLEncoding = strReturn End Function
It is recommended that you use built-in functions in ASP when encoding in Chinese. Although the above encoding function has been tested N times and no problems have been found, just in case there is a bug.
The above is about ASP encoding and decoding functions, I hope it will be helpful to everyone's learning.