Re: Multibyte strings
| From: | Kirill Nesmeyanov | Date: | Fri, 11 Feb 2022 15:41:59 +0000 |
| Subject: | Re: Multibyte strings | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117014@lists.php.net to get a copy of this message | ||
>Пятница, 11 февраля 2022, 9:27 +03:00 от Michał <aaatoja@o2.pl>:
>
>Hi everyone.
>It's a known fact that nowadays most websites use at least UTF-8
>encoding. Unfortunately PHP itself has stopped a bit in the previous
>century. Is there any reason why the mbstring extension cannot be
>introduced to core in the next major version (maybe preceded with a
>deprecation message like it was with the mysql extension in v5)? All
>functions from the standard library would become aliases for multibyte
>equivalents.
>
>--
>PHP Internals - PHP Runtime Development Mailing List
>To unsubscribe, visit: https://www.php.net/unsub.php
Hello, Michal!
The functions for getting the length in bytes and the functions for getting the length of a string
in characters are different functions for different tasks.
That is,
mb_strlen is not equivalent to strlen and cannot replace it:
```
$string = ‘Hell 😁 or 😎 world!’;
echo ‘Bytes: ’ . \strlen($string) . "\n";
echo ‘Chars: ‘ . \mb_strlen($string);
```
When you work with data: sockets, row sizes in the database, shared memory, and so on, you operate
with bytes. And the size in characters is rarely required, for example, to format the output in the
console (with utf support).
So answering your question about "when" - the answer is simple: This will never be done,
because these are functions for different tasks ;)
--
Kirill Nesmeyanov