Bug #76708 [Dup]: mb_detect_encoding behaves inconsistenly depending on the argument type
| From: | smokey101stair at gmail dot com | Date: | Sun, 05 Aug 2018 06:21:39 +0000 |
| Subject: | Bug #76708 [Dup]: mb_detect_encoding behaves inconsistenly depending on the argument type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216603@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76708&edit=1
ID: 76708
User updated by: smokey101stair at gmail dot com
Reported by: smokey101stair at gmail dot com
Summary: mb_detect_encoding behaves inconsistenly depending
on the argument type
Status: Duplicate
Type: Bug
Package: mbstring related
Operating System: Irrelevant
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thanks for the explanation.
Previous Comments:
------------------------------------------------------------------------
[2018-08-05 06:17:53] requinix@php.net
Oh. To be clear, the new behavior has the function issue a warning and use the mb_detect_order
value. So option 2.
------------------------------------------------------------------------
[2018-08-05 06:10:45] requinix@php.net
Same cause as the other bug so this got fixed too.
------------------------------------------------------------------------
[2018-08-05 05:51:42] smokey101stair at gmail dot com
Description:
------------
Similar to Bug 76704. mb_detect_encoding()'s second parameter, $encoding_list, takes either an
array of encodings or a comma separated string of encodings. However, its behavior varies depending
on whether an array or string is passed to $encoding_list, when that value contains both a supported
and unsupported encoding.
Test script:
---------------
https://3v4l.org/KTBkK
Expected result:
----------------
Honestly.. I'm not entirely sure.
Setting mb_detect_encodings()'s second parameter is really doing the same thing as if you had
passed the same thing to mb_detect_order(), which returns false (now that Bug 76704 is fixed) if any
of the given encodings are not supported.
Option 1) In the interest of consistency, this should probably also return false if any of the given
encodings are not supported. Doing this would probably be a a BC break, and I don't know how
popular this function really is.
Option 2) Match what is currently done when an array is given and emit a warning and silently
fallback to the value of mb_detect_order().
Option 3) Match what is currently done when a string is given and silently try to match against any
of the supported encodings.
Actual result:
--------------
If $encoding_list is a string, and tries to match the given string against the supported encoding.
No warning is emitted.
If $encoding_list is an array, then a warning is emitted and it tries to match the given string
against the fallback value of mb_detect_order().
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76708&edit=1