[php-src] Issue #9069: The order of `$encodings` parameter in `mb_detect_encoding()` is sometimes ignored
| From: | machitgarha | Date: | Wed, 20 Jul 2022 15:44:09 +0000 |
| Subject: | [php-src] Issue #9069: The order of `$encodings` parameter in `mb_detect_encoding()` is sometimes ignored | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241960@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9069
Author: machitgarha
### Description
The PHP documentation says:
> ####
$encodings
>
> A list of character encodings to try, **in order**. The list may be specified as an array of
> strings, or a single string separated by commas.
But in PHP 8.1, it *may* not be regarded.
The following code:
```php
echo mb_detect_encoding('$x + 2', ['UTF-7', 'UTF-8']) . PHP_EOL;
echo mb_detect_encoding('$x + 2', ['UTF-8', 'UTF-7']) . PHP_EOL;
```
Resulted in this output:
```
UTF-7
UTF-7
```
But I expected this output instead:
```
UTF-7
UTF-8
```
Maybe related to #9008, but I felt like opening a new one is better.
### PHP Version
PHP 8.1.8
### Operating System
Fedora Workstation 36