note 118804 added to function.chr

From: Date: Tue, 09 Feb 2016 01:01:34 +0000
Subject: note 118804 added to function.chr
Groups: php.notes 
Request: Send a blank email to php-notes+get-204902@lists.php.net to get a copy of this message
Another quick function to get unicode char by its code. <?php function unichr($dec) { if ($dec < 0x80) { $utf = chr($dec); } else if ($dec < 0x0800) { $utf = chr(0xC0 + ($dec >> 6)); $utf .= chr(0x80 + ($dec & 0x3f)); } else if ($dec < 0x010000) { $utf = chr(0xE0 + ($dec >> 12)); $utf .= chr(0x80 + (($dec >> 6) & 0x3f)); $utf .= chr(0x80 + ($dec & 0x3f)); } else if ($dec < 0x200000) { $utf = chr(0xF0 + ($dec >> 18)); $utf .= chr(0x80 + (($dec >> 12) & 0x3f)); $utf .= chr(0x80 + (($dec >> 6) & 0x3f)); $utf .= chr(0x80 + ($dec & 0x3f)); } else { die("UTF-8 character size is more than 4 bytes"); } return $utf; } echo unichr(0x263A); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 91.76.136.193 ---- Manual Page -- http://php.net/manual/en/function.chr.php Edit -- https://master.php.net/note/edit/118804 Del: integrated -- https://master.php.net/note/delete/118804/integrated Del: useless -- https://master.php.net/note/delete/118804/useless Del: bad code -- https://master.php.net/note/delete/118804/bad+code Del: spam -- https://master.php.net/note/delete/118804/spam Del: non-english -- https://master.php.net/note/delete/118804/non-english Del: in docs -- https://master.php.net/note/delete/118804/in+docs Del: other reasons-- https://master.php.net/note/delete/118804 Reject -- https://master.php.net/note/reject/118804 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204902) next »