note 123788 added to function.mb-chr
| From: | boss3333 at laposte dot net | Date: | Sat, 20 Apr 2019 14:43:56 +0000 |
| Subject: | note 123788 added to function.mb-chr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210629@lists.php.net to get a copy of this message | ||
To convert the utf16 or utf8 decimal values (utf-8 can translate both encodings) to ascii characters
using mb_ord, follow these steps:
Starting value:
1_Zvpxs4pf
Value converted to decimal value utf-16 or utf-8 (see ascii coding table):
49,95,90,118,112,120,115,52,112,102
recovery with mb_ord:
use: $ char = mb_chr ($ decimalValue, 'UTF-8');
return the correct character;
1, _, Z, v, p, x, s, 4, p, f
example:
$ start_String = 1_Zvpxs4pf;
$ start_String_to_Decimal = 49959011811212011552112102;
(decimal value of each character add in an array);
$ tab = [49, 95, 90, 118, 112, 120, 115, 52, 112, 102];
$ size = sizeof ($ tab);
$ tmpStr = '';
for ($ i = 0; $ i <$ size; $ i ++)
{
$ tmpStr. = mb_chr ($ tab [$ i], 'UTF-8');
}
echo $ tmpStr;
1_Zvpxs4pf
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.130.26 (proxied: 2a01:e34:eee5:aa40:217d:ef29:735:6016)
----
Manual Page -- http://php.net/manual/en/function.mb-chr.php
Edit -- https://master.php.net/note/edit/123788
Del: integrated -- https://master.php.net/note/delete/123788/integrated
Del: useless -- https://master.php.net/note/delete/123788/useless
Del: bad code -- https://master.php.net/note/delete/123788/bad+code
Del: spam -- https://master.php.net/note/delete/123788/spam
Del: non-english -- https://master.php.net/note/delete/123788/non-english
Del: in docs -- https://master.php.net/note/delete/123788/in+docs
Del: other reasons-- https://master.php.net/note/delete/123788
Reject -- https://master.php.net/note/reject/123788
Search -- https://master.php.net/manage/user-notes.php