note 99182 added to function.utf8-decode
| From: | anonymous at osu1 dot php dot net | Date: | Sun, 01 Aug 2010 13:18:36 +0000 |
| Subject: | note 99182 added to function.utf8-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171300@lists.php.net to get a copy of this message | ||
function charset_decode_utf_8($string) {
/* modification of charset_decode_utf_8
// use preg instead of ereg
// 4 bytes are also decoded
128 200 10000000 , 240 360 11110000 224 340 11100000 128 200 10000000
255 377 11111111 , 247 367 11110111 239 357 11101111 191 277 10111111
*/
if (!preg_match("/[\200-\377]/", $string)) return $string; // ereg
$string = preg_replace(
"/([\360-\367])([\200-\277])([\200-\277])([\200-\277])/e",
"'&#'.((ord('\\1')-240)*262144 + (ord('\\2')-128)*4096 +
(ord('\\3')-128)*64 + (ord('\\4')-128)).';'", $string);
$string = preg_replace(
"/([\340-\357])([\200-\277])([\200-\277])/e",
"'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 +
(ord('\\3')-128)).';'", $string);
$string = preg_replace(
"/([\300-\337])([\200-\277])/e",
"'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'",$string);
return $string;
}
$tab=array('$','é','â¬', 'ð¤¢'); //,$pangramme);
foreach($tab as $k1 => $v1){
$ht1.='<p><span style="font-size:60px;">' . $v1 . ' = ' .
charset_decode_utf_8($v1) . ' </span>' .
strlen($v1) . ' bytes , ' . '' .
str_replace('&','&',charset_decode_utf_8($v1)) . '' .
'</p>'."\r\n" ;
}
echo $ht1;
----
Server IP: 69.147.83.197
Probable Submitter: 84.97.242.192
----
Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php
Edit -- https://master.php.net/note/edit/99182
Del: integrated -- https://master.php.net/note/delete/99182/integrated
Del: useless -- https://master.php.net/note/delete/99182/useless
Del: bad code -- https://master.php.net/note/delete/99182/bad+code
Del: spam -- https://master.php.net/note/delete/99182/spam
Del: non-english -- https://master.php.net/note/delete/99182/non-english
Del: in docs -- https://master.php.net/note/delete/99182/in+docs
Del: other reasons-- https://master.php.net/note/delete/99182
Reject -- https://master.php.net/note/reject/99182
Search -- https://master.php.net/manage/user-notes.php