Forum Moderators: open

Message Too Old, No Replies

URL escape characters not being interpreted

         

penstaar

6:50 pm on Feb 26, 2007 (gmt 0)

10+ Year Member



Hi there,

I'm just learning about using hex encoding to escape certain special characters in a URL, ie '&' or '?'

So shouldn't this example URL:
http://www.example.com/subpage.asp%3FsectionID%3D752

be interpreted by my browser as:
http://www.example.com/subpage.asp?sectionID=752

and therefore take me to http://www.example.com/subpage.asp?sectionID=752

Thanks for any help!

[edited by: encyclo at 7:12 pm (utc) on Feb. 26, 2007]
[edit reason] switched to example.com [/edit]

penders

10:22 pm on Feb 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't think you want to be encoding those special characters (&,?) in this instance, as you want them to stay as special characters... marking the start of the querystring (?) and delimiting the key/value pairs in the querystring (&)...

If you encode the URL as you have done, then I think it's going to try and find a file called: "subpage.asp%3FsectionID%3D752" - which I suspect doesn't exist?!

I recon you only need to encode/escape the actual 'values' that are being past in the URL. ie. 752 in your case (which doesn't actually need encoding). However, if you wanted to pass:

http://www.example.com/subpage.asp?sectionID=some text

Then the 'space' would need to be encoded:

http://www.example.com/subpage.asp?sectionID=some%20text

penstaar

6:38 pm on Feb 28, 2007 (gmt 0)

10+ Year Member



The reason I wanted to encode the special characters is because when I have a URL with a '?' in it in a mailto link, the stuff after the? gets truncated.

ie http://www.example.com/subpage.asp?sectionID=752

becomes just http://www.example.com/subpage.asp

[edited by: encyclo at 6:56 pm (utc) on Feb. 28, 2007]
[edit reason] switched to example.com [/edit]