Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

i have following string with "+" sign in the end. I have used javascript escape function to encode "+" as it is. But when i execute this url, i am not getting "+" leading wrong result. How to decode this string so that i will get proper string?

http://xyz.com/test.asp?id=SF&pnam=722%25%20IT%20Sf%20Con%3C100%3E2year21+


Thanks
Posted

1 solution

Try this:

http://xyz.com/test.asp?id=SF&pnam=722%25%20IT%20Sf%20Con%3C100%3E2year21%2B

The URL encoding char for a + sign is %2B

Hope this helps.
 
Share this answer
 
v3
Comments
PleaseHelpCP 30-Oct-12 6:06am    
Tried this but not working. I am using frames. If i check page properties, i get correct url i.e. with encoded 2B. But if i try to retrieve using request.querystring, its not showing blank space.
Thomas Daniels 30-Oct-12 6:09am    
What's the code you use?
PleaseHelpCP 30-Oct-12 6:19am    
tried using replace function of javascript
Thomas Daniels 30-Oct-12 6:20am    
I need the code that you use. Otherwise, I can't know exactly what you do.
PleaseHelpCP 30-Oct-12 6:26am    
tried 2 ways.

1. pnam = Decode(Encode(request.querystring("pnam")))

Function Decode(sIn)
dim x, y, abfrom, abto
Decode="": ABFrom = ""

For x = 0 To 25: ABFrom = ABFrom & Chr(65 + x): Next
For x = 0 To 25: ABFrom = ABFrom & Chr(97 + x): Next
For x = 0 To 9: ABFrom = ABFrom & CStr(x): Next

abto = Mid(abfrom, 14, Len(abfrom) - 13) & Left(abfrom, 13)
For x=1 to Len(sin): y=InStr(abto, Mid(sin, x, 1))
If y = 0 then
Decode = Decode & Mid(sin, x, 1)
Else
Decode = Decode & Mid(abfrom, y, 1)
End If
Next
End Function

' USE: location.href="nextpage.asp?" & encode("sParm=" & sData)

Function Encode(sIn)
dim x, y, abfrom, abto
Encode="": ABFrom = ""

For x = 0 To 25: ABFrom = ABFrom & Chr(65 + x): Next
For x = 0 To 25: ABFrom = ABFrom & Chr(97 + x): Next
For x = 0 To 9: ABFrom = ABFrom & CStr(x): Next

abto = Mid(abfrom, 14, Len(abfrom) - 13) & Left(abfrom, 13)
For x=1 to Len(sin): y = InStr(abfrom, Mid(sin, x, 1))
If y = 0 Then
Encode = Encode & Mid(sin, x, 1)
Else
Encode = Encode & Mid(abto, y, 1)
End If
Next
End Function

and other is javascript replace
str.replace(str,"+","####")

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900