note 64676 added to function.urldecode
| From: | rosty dot kerei at gmail dot com | Date: | Wed, 19 Apr 2006 16:40:33 +0000 |
| Subject: | note 64676 added to function.urldecode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108643@lists.php.net to get a copy of this message | ||
This function doesn't decode unicode characters. I wrote a function that does.
function unicode_urldecode($url)
{
preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);
foreach ($a[1] as $uniord)
{
$dec = hexdec($uniord);
$utf = '';
if ($dec < 128)
{
$utf = chr($dec);
}
else if ($dec < 2048)
{
$utf = chr(192 + (($dec - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
}
else
{
$utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
}
$url = str_replace('%u'.$uniord, $utf, $url);
}
return urldecode($url);
}
----
Server IP: 216.194.113.175
Probable Submitter: 213.160.130.146 (proxied: 192.168.0.124)
----
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/64676
Del: integrated -- http://master.php.net/note/delete/64676/integrated
Del: useless -- http://master.php.net/note/delete/64676/useless
Del: bad code -- http://master.php.net/note/delete/64676/bad+code
Del: spam -- http://master.php.net/note/delete/64676/spam
Del: non-english -- http://master.php.net/note/delete/64676/non-english
Del: in docs -- http://master.php.net/note/delete/64676/in+docs
Del: other reasons-- http://master.php.net/note/delete/64676
Reject -- http://master.php.net/note/reject/64676
Search -- http://master.php.net/manage/user-notes.php