note 41293 deleted from function.utf8-encode by cmb
| From: | cmb@php.net | Date: | Sun, 22 Dec 2019 09:03:56 +0000 |
| Subject: | note 41293 deleted from function.utf8-encode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213586@lists.php.net to get a copy of this message | ||
Note Submitter: lorro at lorro dot wigner dot bme dot hu
----
Good news is that utf8_encode (like UTF-8) passes '<', '>', '/',
'\'', '"', etc., so you are free to utf8_encode complete blocks of
html text that includes tags.
Bad news is that UTF-8 is stupid enough so that utf8_encode(utf8_encode($str)) != utf8_encode($str)
in most of the cases. What you can do is write utf8_ensure like:
function utf8_ensure($str) {
return seems_utf8($str)? $str: utf8_encode($str);
}
Comes handy when your view library tries to encode the same text multiple times.