note 63889 deleted from function.urldecode by bjori

From: Date: Mon, 03 Apr 2006 11:46:53 +0000
Subject: note 63889 deleted from function.urldecode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107222@lists.php.net to get a copy of this message
Note Submitter: todd dot kisov at yahoo dot com ---- To convert query string parameter values ($_GET, $_REQUEST), which include escaped Unicode values resulting from applying the JavaScript "escape" function to a Unicode string (%uNNNN%uNNNN%uNNNN) fast and simple is to use PECL JSON extension: function JavaScript_Unicode_URL_2_Str($js_uni_str) { $res = preg_replace('/%u([[:alnum:]]{4})/', '\\u\1', $js_uni_str); $res = str_replace('"', '\"', $res); // if in str " $res = json_decode('["'.$res.'"]'); // JavaScrip array with string element $res = $res[0]; $res = iconv('UTF-8', ini_get('default_charset'), $res); return $res; }

« previous php.notes (#107222) next »