I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces all the special characters back but sapce is replaced by '+'. how can i do it correctly so that space is replaced as space itself???
Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
Join them; it only takes a minute:
Try using rawurlencode instead - urlencode does some things differently for "historical" reasons. See http://us.php.net/manual/en/function.urlencode.php for more information. |
|||||
|
PHP rawUrlEncode() == JavaScript encodeURIComponent() PHP rawUrlDecode() == JavaScript decodeURIComponent() |
|||||||||||||
|
Try this:
|
|||||
|
Parenthesis are exceptions to all of what is said in this post. geek mode on : false
but true
In other words, there are many special characters that aren't treated as safe in rawurlencode when they are in encodeURIComponent. |
|||
|