note 89992 added to function.mb-decode-numericentity
| From: | Navi at osu1 dot php dot net | Date: | Wed, 01 Apr 2009 09:00:09 +0000 |
| Subject: | note 89992 added to function.mb-decode-numericentity | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152686@lists.php.net to get a copy of this message | ||
Manual entity => utf8 conversion:
<?php
// parse entities
$raw = preg_replace_callback
(
"/&#(\\d+);/u",
"_pcreEntityToUtf",
$raw
);
function _pcreEntityToUtf($matches)
{
$char = intval(is_array($matches) ? $matches[1] : $matches);
if ($char < 0x80)
{
// to prevent insertion of control characters
if ($char >= 0x20) return htmlspecialchars(chr($char));
else return "&#$char;";
}
else if ($char < 0x8000)
{
return chr(0xc0 | (0x1f & ($char >> 6))) . chr(0x80 | (0x3f & $char));
}
else
{
return chr(0xe0 | (0x0f & ($char >> 12))) . chr(0x80 | (0x3f & ($char >>
6))). chr(0x80 | (0x3f & $char));
}
}
----
Server IP: 78.41.104.4
Probable Submitter: 77.51.76.124
----
Manual Page -- http://www.php.net/manual/en/function.mb-decode-numericentity.php
Edit -- https://master.php.net/note/edit/89992
Del: integrated -- https://master.php.net/note/delete/89992/integrated
Del: useless -- https://master.php.net/note/delete/89992/useless
Del: bad code -- https://master.php.net/note/delete/89992/bad+code
Del: spam -- https://master.php.net/note/delete/89992/spam
Del: non-english -- https://master.php.net/note/delete/89992/non-english
Del: in docs -- https://master.php.net/note/delete/89992/in+docs
Del: other reasons-- https://master.php.net/note/delete/89992
Reject -- https://master.php.net/note/reject/89992
Search -- https://master.php.net/manage/user-notes.php