note 48892 deleted from function.utf8-encode by cmb

From: Date: Sun, 22 Dec 2019 08:56:45 +0000
Subject: note 48892 deleted from function.utf8-encode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213568@lists.php.net to get a copy of this message
Note Submitter: schofei at yahoo dot de ---- regarding the above code2utf function... > romans at void dot lv > 02-Oct-2002 09:59 > Here is optimized function which converts > binary UTF symbol code into unicoded string.... Thanks for providing your nice conversion code, however due to some missing parenthesis 4-byte utf-8 chars are not converted properly. Here is a corrected version of the code2utf function: 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 ''; } regards Scho Fei

« previous php.notes (#213568) next »