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

From: 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

« previous php.bugs (#235885) next »