note 63889 added to function.urldecode
| From: | todd dot kisov at yahoo dot com | Date: | Mon, 03 Apr 2006 09:11:14 +0000 |
| Subject: | note 63889 added to function.urldecode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107212@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 195.149.248.161
Probable Submitter: 195.149.251.50 (proxied: 192.168.250.114)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.urldecode.php
Edit -- http://master.php.net/note/edit/63889
Del: integrated -- http://master.php.net/note/delete/63889/integrated
Del: useless -- http://master.php.net/note/delete/63889/useless
Del: bad code -- http://master.php.net/note/delete/63889/bad+code
Del: spam -- http://master.php.net/note/delete/63889/spam
Del: non-english -- http://master.php.net/note/delete/63889/non-english
Del: in docs -- http://master.php.net/note/delete/63889/in+docs
Del: other reasons-- http://master.php.net/note/delete/63889
Reject -- http://master.php.net/note/reject/63889
Search -- http://master.php.net/manage/user-notes.php