Bug #81665 [Opn->Nab]: mb_detect_encoding() should return false
Edit report at https://bugs.php.net/bug.php?id=81665&edit=1
ID: 81665
Updated by: requinix@php.net
Reported by: alec at alec dot pl
Summary: mb_detect_encoding() should return false
-Status: Open
+Status: Not a bug
Type: Bug
Package: mbstring related
PHP Version: 8.1.0
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
https://www.php.net/manual/en/function.mb-detect-encoding.php
> 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.
https://3v4l.org/TUqZ1
Previous Comments:
------------------------------------------------------------------------
[2021-11-27 08:16:05] alec at alec dot pl
Description:
------------
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.
https://3v4l.org/km1R7
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:
----------------
invalid:false
Actual result:
--------------
invalid:UTF-8
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81665&edit=1
Thread (3 messages)