-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
The following code:
<?php
$encodings = [
'UTF-8',
'UTF-16',
'UTF-32',
'ISO-8859-1',
'ISO-8859-2',
'ISO-8859-6',
'ISO-8859-15',
'ASCII'
];
$a = 'NL';
echo mb_detect_encoding($a, $encodings, true);
Resulted in this output:
'UTF-16'
But I expected this output instead:
'UTF-8'
This worked correctly in 8.0, and was broken from that point onward. Just the string 'NL' is valid UTF-8. It's also valid UTF-16 of course, but UTF-8 is first in the list, so I expect it to be picked first. If the string contained UTF-16 characters, only then would I expect it to return 'UTF-16'
Sandbox: https://onlinephp.io/c/86885
PHP Version
PHP 8.3.12
Operating System
No response