note 124827 added to function.mb-ord
| From: | Andrew@php.net | Date: | Sat, 14 Mar 2020 18:40:10 +0000 |
| Subject: | note 124827 added to function.mb-ord | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214333@lists.php.net to get a copy of this message | ||
You can forget about DIY uniord()
https://www.php.net/manual/en/function.ord.php#42778
$array['Ð'] = uniord('Ð');
$array['ð·'] = uniord('ð·');
$array['mb_ord Ð'] = mb_ord('Ð');
$array['mb_ord ð·'] = mb_ord('ð·');
function uniord($charUTF8)
{
$charUCS4 = mb_convert_encoding($charUTF8, 'UCS-4BE', 'UTF-8');
$byte1 = ord(substr($charUCS4, 0, 1));
$byte2 = ord(substr($charUCS4, 1, 1));
$byte3 = ord(substr($charUCS4, 2, 1));
$byte4 = ord(substr($charUCS4, 3, 1));
return ($byte1 << 32) + ($byte2 << 16) + ($byte3 << 8) + $byte4;
}
var_export($array);
Shows:
array ( 'Ð' => 1041, 'ð·' => 128695, 'mb_ord Ð'
=> 1041, 'mb_ord ð·' => 128695, )
https://unicode-table.com/en/0411/
Ð
Encoding hex dec (bytes) dec binary
UTF-8 D0 91 208 145 53393 11010000 10010001
UTF-16BE 04 11 4 17 1041 00000100 00010001
UTF-16LE 11 04 17 4 4356 00010001 00000100
UTF-32BE 00 00 04 11 0 0 4 17 1041 00000000 00000000 00000100 00010001
UTF-32LE 11 04 00 00 17 4 0 0 285474816 00010001 00000100 00000000 00000000
https://unicode-table.com/en/1F6B7/
ð·
Encoding hex dec (bytes) dec binary
UTF-8 F0 9F 9A B7 240 159 154 183 4036991671 11110000 10011111 10011010 10110111
UTF-16BE D8 3D DE B7 216 61 222 183 3627933367 11011000 00111101 11011110 10110111
UTF-16LE 3D D8 B7 DE 61 216 183 222 1037613022 00111101 11011000 10110111 11011110
UTF-32BE 00 01 F6 B7 0 1 246 183 128695 00000000 00000001 11110110 10110111
UTF-32LE B7 F6 01 00 183 246 1 0 3086352640 10110111 11110110 00000001 00000000
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.195 (proxied: 94.242.24.132)
----
Manual Page -- http://php.net/manual/en/function.mb-ord.php
Edit -- https://master.php.net/note/edit/124827
Del: integrated -- https://master.php.net/note/delete/124827/integrated
Del: useless -- https://master.php.net/note/delete/124827/useless
Del: bad code -- https://master.php.net/note/delete/124827/bad+code
Del: spam -- https://master.php.net/note/delete/124827/spam
Del: non-english -- https://master.php.net/note/delete/124827/non-english
Del: in docs -- https://master.php.net/note/delete/124827/in+docs
Del: other reasons-- https://master.php.net/note/delete/124827
Reject -- https://master.php.net/note/reject/124827
Search -- https://master.php.net/manage/user-notes.php