Bug #81366 [Opn->Dup]: mb_detect_encoding behaving different and failing to detect UTF-8
| From: | nikic@php.net | Date: | Mon, 16 Aug 2021 19:56:25 +0000 |
| Subject: | Bug #81366 [Opn->Dup]: mb_detect_encoding behaving different and failing to detect UTF-8 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235885@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81366&edit=1
ID: 81366
Updated by: nikic@php.net
Reported by: martin at herndl dot org
Summary: mb_detect_encoding behaving different and failing to
detect UTF-8
-Status: Open
+Status: Duplicate
Type: Bug
Package: mbstring related
Operating System: macOS
PHP Version: 8.1.0beta2
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #81349 (fixed in next beta).
Previous Comments:
------------------------------------------------------------------------
[2021-08-16 19:49:48] martin at herndl dot org
A simpler example that I just found:
Test script:
---------------
<?php
var_dump(mb_detect_encoding(' § ', null, true));
Expected result:
----------------
string(5) "UTF-8"
Actual result:
--------------
string(5) "ASCII"
------------------------------------------------------------------------
[2021-08-16 19:14:32] martin at herndl dot org
Description:
------------
mb_detect_encoding with ommited encodings (= null as argument => fallback to default detect
order) behaves different on 8.1.0beta2 and fails to detect UTF-8 in some cases with out-of-the-box
settings.
I noticed this via the
ApplicationTest::testRenderExceptionWithDoubleWidthCharacters
test from Symfony in https://github.com/symfony/symfony/issues/41552
that broke because it converted UTF-8 to UTF-8 again.
Test script:
---------------
<?php
var_dump(mb_detect_order());
var_dump(mb_detect_encoding('ã³ãã³ãã®å®è¡ä¸ã«ã¨ã©ã¼ãçºçãã¾ããã',
null, true));
var_dump(mb_detect_encoding('ã³ãã³ãã®å®è¡ä¸ã«ã¨ã©ã¼ãçºçãã¾ãã',
null, true));
Expected result:
----------------
array(2) {
[0]=>
string(5) "ASCII"
[1]=>
string(5) "UTF-8"
}
string(5) "UTF-8"
string(5) "UTF-8"
Actual result:
--------------
array(2) {
[0]=>
string(5) "ASCII"
[1]=>
string(5) "UTF-8"
}
string(5) "ASCII"
string(5) "UTF-8"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81366&edit=1