Decodes a URL encoded string back into the original text.
Similar to MyURLDecode, but in another approach.
<%
Private Function URLDecode(byVal encodedstring)
Dim strIn, strOut, intPos, strLeft
Dim strRight, intLoop
strIn = encodedstring : strOut = "" : intPos = Instr(strIn, "+")
Do While intPos
strLeft = "" : strRight = ""
If intPos > 1 then strLeft = Left(strIn, intPos - 1)
If intPos < len(strIn) then strRight = Mid(strIn, intPos + 1)
strIn = strLeft & " " & strRight
intPos = InStr(strIn, "+")
intLoop = intLoop + 1
Loop
intPos = InStr(strIn, "%")
Do while intPos
If intPos > 1 then strOut = strOut & Left(strIn, intPos - 1)
strOut = strOut & Chr(CInt("&H" & mid(strIn, intPos + 1, 2)))
If intPos > (len(strIn) - 3) then
strIn = ""
Else
strIn = Mid(strIn, intPos + 3)
End If
intPos = InStr(strIn, "%")
Loop
URLDecode = strOut & strIn
End Function
% >
Private Function URLDecode(byVal encodedstring)
Dim strIn, strOut, intPos, strLeft
Dim strRight, intLoop
strIn = encodedstring : strOut = "" : intPos = Instr(strIn, "+")
Do While intPos
strLeft = "" : strRight = ""
If intPos > 1 then strLeft = Left(strIn, intPos - 1)
If intPos < len(strIn) then strRight = Mid(strIn, intPos + 1)
strIn = strLeft & " " & strRight
intPos = InStr(strIn, "+")
intLoop = intLoop + 1
Loop
intPos = InStr(strIn, "%")
Do while intPos
If intPos > 1 then strOut = strOut & Left(strIn, intPos - 1)
strOut = strOut & Chr(CInt("&H" & mid(strIn, intPos + 1, 2)))
If intPos > (len(strIn) - 3) then
strIn = ""
Else
strIn = Mid(strIn, intPos + 3)
End If
intPos = InStr(strIn, "%")
Loop
URLDecode = strOut & strIn
End Function
% >
byVal encodedstring
Views 899
Downloads 344
CodeID
DB ID
ANmarAmdeen
602
Revisions
v1.0
Friday
August
21
2020