[php-src] Issue #8279: mb_detect_encoding does not return the first matching encoding anymore
| From: | alexdowad | Date: | Mon, 25 Apr 2022 16:12:43 +0000 |
| Subject: | [php-src] Issue #8279: mb_detect_encoding does not return the first matching encoding anymore | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241232@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8279
Comment Author: alexdowad
Please disregard my question about 'what language these are from'. I did a bit of
searching on the web and found my own answers.
> It was reported to us that the problem was happening on common slavic names. I tried several
> names from https://en.wikipedia.org/wiki/Slavic_names and found that
> both 'Dušan' and 'Živko' are wrongly detected as latin1. I understand that
> detecting encoding on a short string is hard but it is a problem that the function is failing on
> common words, and it should in this case use the order of the passed encoding to return the first
> valid one as before.
Certainly, it is a problem, and I would like to thank you for reporting it. While I respect your
view, I do not (at present) agree that
mb_detect_encoding should rely on the order of
the passed encodings in this case. However, I am always ready to be convinced by a logical argument.
What may be more pertinent, and which we *do* agree on, is that mb_detect_encoding
should definitely return 'UTF-8' in this case. I believe that #8439 is the best resolution
to this issue. If you would like to review that commit and leave some comments, please do so.
Also, you are very right that the new algorithm for mb_detect_encoding should have been
listed as a change from PHP 8.0 to 8.1 in the documentation; if that can still be adjusted, it would
be great.