A decoding problem is encountered when developing with ASP. Although using Request in ASP to get encoded URL strings will automatically decode, but Request.BinaryRead (request.totalbytes) when the post data is not decoded, so can only manually decode.
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
next
urldecode=destr End
function
Just a personal hobby, I studied the coding of the implementation of ideas, and finally wrote a code function, to provide you with reference. Note: ASP has the built-in coding function, that is 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)/&am P HFF
Low8 = Innercode and &hff
strreturn = strreturn & "%" & Hex (HIGHT8) & "%" & Hex (LOW8)
end If
Next
urlencoding = Strreturn End
Function
It is recommended that you use the ASP built-in functions when coding in Chinese. Although the above coded function has been tested n times, no problems have been identified, but in case there is a bug.
The above is about ASP encoding and decoding functions, I hope to help you learn.