I think this is a basic question, however, for some reason my small and simple script won't work ..
Since my framework don't allow special characters, I have to encode an url. So for example domain.com/This_is_a_heart_♥ becomes domain.com/This_is_a_heart_%E2%99%A5
But when I paste the second URL in the browser, the browser converts it back to domain.com/This_is_a_heart_♥ so the framework throws an error again.
How can I fix this? :)
12-05-2012, 05:07 PM
Use encodeURI() or encodeURIComponent() to encode URLs.
12-05-2012, 06:06 PM
Yes, that's exactly what I'm doing. I use encodeURIComponent() to encode URL's but like said, the encoding itself works fine, but when I paste the following url in the webbrowser (i use chrome) the encoded url is decoded again, and my framework throws an error because 'illigal' characters are used.
Try for yourself. Copy/paste the following url in the webbrowser and look at the URL. You'll see a heart at the end, instead of the encoding. domain.com/This_is_a_heart_%E2%99%A5
Thanks for help!
12-06-2012, 12:47 AM
Ah, I see what you mean. Perhaps you could encode the URL twice then? So you'd get domain.com/This_is_a_heart_%25E2%2599%25A5 which Chrome doesn't seem to automatically decode.
12-06-2012, 02:45 PM
Hmm, that does work but doesn't seem the correct way to do it :)