Search Tools Links Login

Lewies URLDecode

Posted: 2002-06-01
By: ArchiveBot
Viewed: 54

Filed Under:


No attachments for this post

Xao Xiong originally posted his version
of DecodeURL and asked for a reply for
a better way. I replied, but it didn't
turn out too well, so i'm posting it here
for him to see.
The approach i took is that when you look
at an encoded URL string, 2 hex characters
follow a percent sign. XAO listed a few
to translate into actual characters, but
he didn't account for all 256 of them.
Check it out!

Original Author: Lewis E. Moten III


Response.Write DecodeURL("")
Function DecodeURL(ByRef pstrURL)
Dim llngIndex
Dim llngMaxIndex
Dim lstrChar
Dim lstrResult

llngMaxIndex = Len(pstrURL)
llngIndex = 1

Do While llngIndex <= llngMaxIndex
lstrChar = Mid(pstrURL, llngIndex, 1)
If lstrChar = "%" Then
lstrResult = lstrResult & chr("&h" & Mid(pstrURL, llngIndex + 1, 2))
llngIndex = llngIndex + 3
ElseIf lstrChar = "+" Then
lstrResult = lstrResult & " "
llngIndex = llngIndex + 1
lstrResult = lstrResult & lstrChar
llngIndex = llngIndex + 1
End If

DecodeURL = lstrResult
End Function

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.