Bug #81366 [Opn]: mb_detect_encoding behaving different and failing to detect UTF-8

From: Date: Mon, 16 Aug 2021 19:49:48 +0000
Subject: Bug #81366 [Opn]: 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-235884@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 User updated by: martin at herndl dot org Reported by: martin at herndl dot org Summary: mb_detect_encoding behaving different and failing to detect UTF-8 Status: Open Type: Bug Package: mbstring related Operating System: macOS PHP Version: 8.1.0beta2 Block user comment: N Private report: N New Comment: 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" Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#235884) next »