note 63161 deleted from function.bin2hex by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:53:41 +0000 |
| Subject: | note 63161 deleted from function.bin2hex by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196696@lists.php.net to get a copy of this message | ||
Note Submitter: mike at go dot online dot pt
----
Unicode/multibyte capable 'bin2hex' function, inspired by v0rbiz at yahoo dot com >>
http://www.php.net/manual/en/function.ord.php#42778
function unibin2hex($u) {
$k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
$k1 = bin2hex(substr($k, 0, 1));
$k2 = bin2hex(substr($k, 1, 1));
return $k2.$k1;
}
Note: UCS-2LE = UCS-2 little endian; UCS-2 = UTF-16