note 70561 added to function.utf8-decode
| From: | tobias at code-x dot de | Date: | Fri, 20 Oct 2006 12:13:19 +0000 |
| Subject: | note 70561 added to function.utf8-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118840@lists.php.net to get a copy of this message | ||
converting uft8-html sign ĭ to uft8
<?
function uft8html2utf8( $s ) {
if ( !function_exists('uft8html2utf8_callback') ) {
function uft8html2utf8_callback($t) {
$dec = $t[1];
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));
}
return $utf;
}
}
return preg_replace_callback('|&#([0-9]{1,});|', 'uft8html2utf8_callback',
$s );
}
echo uft8html2utf8('test: ĭ');
?>
----
Server IP: 212.124.37.9
Probable Submitter: 80.70.180.42
----
Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php
Edit -- https://master.php.net/note/edit/70561
Del: integrated -- https://master.php.net/note/delete/70561/integrated
Del: useless -- https://master.php.net/note/delete/70561/useless
Del: bad code -- https://master.php.net/note/delete/70561/bad+code
Del: spam -- https://master.php.net/note/delete/70561/spam
Del: non-english -- https://master.php.net/note/delete/70561/non-english
Del: in docs -- https://master.php.net/note/delete/70561/in+docs
Del: other reasons-- https://master.php.net/note/delete/70561
Reject -- https://master.php.net/note/reject/70561
Search -- https://master.php.net/manage/user-notes.php