|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81665 mb_detect_encoding() should return false
Submitted: 2021-11-27 08:16 UTC Modified: 2021-11-27 08:19 UTC
From: alec at alec dot pl Assigned:
Status: Closed Package: mbstring related
PHP Version: 8.1.0 OS:
Private report: No CVE-ID: None
 [2021-11-27 08:16 UTC] alec at alec dot pl
mb_detect_encoding() according to the documentation should return "false if the string is not valid in any of the listed encodings".

However, the test script shows that this is not the case.

Related to bug #48210 which has been closed without proper evaluation, imo. I hope, my test script is more clear about the issue.

Test script:
$test = quoted_printable_decode('Piotr Iksi=F1ski');
echo mb_check_encoding($test, 'UTF-8') ? "valid:" : "invalid:";
echo mb_detect_encoding($test, 'ASCII,UTF-8') ?: 'false';

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-27 08:19 UTC]
-Status: Open +Status: Not a bug
 [2021-11-27 08:19 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at
> strict
> Controls the behaviour when string is not valid in any of the listed encodings.
> If strict is set to false, the closest matching encoding will be returned; if
> strict is set to true, false will be returned.
 [2021-11-27 08:19 UTC] alec at alec dot pl
-Status: Not a bug +Status: Closed
 [2021-11-27 08:19 UTC] alec at alec dot pl
Oops, looks like I missed the meaning of the 3rd argument.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Feb 05 18:03:43 2023 UTC