VB icon

Lewies URLDecode

Email
Submitted on: 1/5/2015 4:09:00 PM
By: Lewis E. Moten III (from psc cd)  
Level: Intermediate
User Rating: By 9 Users
Compatibility: ASP (Active Server Pages)
Views: 602
 
     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! See http://www.planetsourcecode.com/xq/ASP/ txtCodeId.6728/lngWId.4/qx/vb/scripts/ ShowCode.htm
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Lewies URLDecode
' Description: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!
See http://www.planetsourcecode.com/xq/ASP/
txtCodeId.6728/lngWId.4/qx/vb/scripts/
ShowCode.htm
' By: Lewis E. Moten III (from psc cd)
'**************************************

<%
Response.Write DecodeURL("http://www.lewismoten.com/1%2B2%3D3.asp")
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
		Else
			lstrResult = lstrResult & lstrChar
			llngIndex = llngIndex + 1
		End If
	Loop
	
	DecodeURL = lstrResult
End Function
%>


Other 63 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.