Created
February 24, 2014 06:46
-
-
Save nordinrahman/9183032 to your computer and use it in GitHub Desktop.
ASP code to URL-decode a query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' ----------------------------------------- | |
' URL decode to retrieve the original value | |
' ----------------------------------------- | |
Function URLDecode(sConvert) | |
Dim aSplit | |
Dim sOutput | |
Dim I | |
If IsNull(sConvert) Then | |
URLDecode = "" | |
Exit Function | |
End If | |
' convert all pluses to spaces | |
sOutput = REPLACE(sConvert, "+", " ") | |
' next convert %hexdigits to the character | |
aSplit = Split(sOutput, "%") | |
If IsArray(aSplit) Then | |
sOutput = aSplit(0) | |
For I = 0 to UBound(aSplit) - 1 | |
sOutput = sOutput & _ | |
Chr("&H" & Left(aSplit(i + 1), 2)) &_ | |
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2) | |
Next | |
End If | |
URLDecode = sOutput | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment