note 109817 deleted from function.chr by danbrown
| From: | danbrown@php.net | Date: | Fri, 31 Aug 2012 15:44:22 +0000 |
| Subject: | note 109817 deleted from function.chr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190324@lists.php.net to get a copy of this message | ||
Note Submitter: alexhacker64 at gmail dot com
----
A bit more improved version of unichr, using the binary ar:
<?php
function unichr($v) {
if (($v & 127) == $v) {
$utf = chr($v);
} else if (($v & 2047) == $v) {
$utf = chr(192 + (($v - ($v & 63)) >> 6));
$utf .= chr(128 + ($v & 63));
} else {
$utf = chr(224 + (($v - ($v & 4095)) >> 11));
$utf .= chr(128 + ((($v & 4095) - ($v & 63)) >> 6));
$utf .= chr(128 + ($v & 63));
}
return $utf;
}
?>