Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unescape a string?

using ajax get method to pass a variable. where i use to escape the string with escape() function.

In php, I receive the value and insert into a database.

How do I unescape the string?

For example, for:

balaji's

I get

balaji%27s.
like image 968
user737767 Avatar asked May 05 '11 07:05

user737767


People also ask

What can I use instead of unescape?

Usually, decodeURI or decodeURIComponent are preferred over unescape . Note: Do not use unescape to decode URIs, use decodeURI instead.

What is unescape () and escape () functions?

The escape() function is used to encode a string, making it safe for use in a URL. The unescape() function is used to decode an encoded string.

What is Unescape?

(programming) To reverse the escaping of a string quotations ▼

What does regex Unescape do?

Converts any escaped characters in the input string.


2 Answers

You can use this function instead of urldecode()

function utf8_urldecode($str) {
        return html_entity_decode(preg_replace("/%u([0-9a-f]{3,4})/i", "&#x\\1;", urldecode($str)), null, 'UTF-8');
}
like image 74
Babailiica Avatar answered Oct 24 '22 22:10

Babailiica


You can try this:

htmlspecialchars(urldecode($str));
like image 43
Shweta Khattar Avatar answered Oct 24 '22 22:10

Shweta Khattar