note 99925 added to function.utf8-encode
| From: | Yumok at osu1 dot php dot net | Date: | Wed, 15 Sep 2010 11:26:21 +0000 |
| Subject: | note 99925 added to function.utf8-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172572@lists.php.net to get a copy of this message | ||
Avoiding use of preg_match to detect if utf8_encode is needed:
$string = $string_input; // avoid being destructive
$string = preg_replace("#[\x09\x0A\x0D\x20-\x7E]#" ,"",$string); // ASCII
$string = preg_replace("#[\xC2-\xDF][\x80-\xBF]#" ,"",$string); //
non-overlong 2-byte
$string = preg_replace("#\xE0[\xA0-\xBF][\x80-\xBF]#" ,"",$string); //
excluding overlongs
$string = preg_replace("#[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}#","",$string);
// straight 3-byte
$string = preg_replace("#\xED[\x80-\x9F][\x80-\xBF]#" ,"",$string); //
excluding surrogates
$string = preg_replace("#\xF0[\x90-\xBF][\x80-\xBF]{2}#","",$string); //
planes 1-3
$string = preg_replace("#[\xF1-\xF3][\x80-\xBF]{3}#" ,"",$string); //
planes 4-15
$string = preg_replace("#\xF4[\x80-\x8F][\x80-\xBF]{2}#","",$string); //
plane 16
$rc = ($string == ""?true:false);
----
Server IP: 69.147.83.197
Probable Submitter: 217.130.241.106
----
Manual Page -- http://www.php.net/manual/en/function.utf8-encode.php
Edit -- https://master.php.net/note/edit/99925
Del: integrated -- https://master.php.net/note/delete/99925/integrated
Del: useless -- https://master.php.net/note/delete/99925/useless
Del: bad code -- https://master.php.net/note/delete/99925/bad+code
Del: spam -- https://master.php.net/note/delete/99925/spam
Del: non-english -- https://master.php.net/note/delete/99925/non-english
Del: in docs -- https://master.php.net/note/delete/99925/in+docs
Del: other reasons-- https://master.php.net/note/delete/99925
Reject -- https://master.php.net/note/reject/99925
Search -- https://master.php.net/manage/user-notes.php