note 25714 deleted from function.utf8-encode by cmb
| From: | cmb@php.net | Date: | Sun, 22 Dec 2019 09:03:31 +0000 |
| Subject: | note 25714 deleted from function.utf8-encode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213585@lists.php.net to get a copy of this message | ||
Note Submitter: romans at void dot lv
----
Here is optimized function which converts binary UTF symbol code into unicoded string.
function code2utf($num){
if($num<128)return chr($num);
if($num<1024)return chr(($num>>6)+192).chr(($num&63)+128);
if($num<32768)return
chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
if($num<2097152)return
chr($num>>18+240).chr((($num>>12)&63)+128).chr(($num>>6)&63+128).
chr($num&63+128);
return '';
}