[php-src] Issue #13746: mb_check_encoding is detecting SJIS as Windows-1252 in PHP 8.1

From: Date: Mon, 18 Mar 2024 17:22:49 +0000
Subject: [php-src] Issue #13746: mb_check_encoding is detecting SJIS as Windows-1252 in PHP 8.1
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246606@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13746 Author: rtio ### Description Works as expected in 7.4 The following code: ```php <?php $string = mb_convert_encoding('パーティーへ行かないか', 'SJIS', 'UTF-8'); var_dump(mb_check_encoding($string, 'SJIS')); // should be valid var_dump(mb_check_encoding($string, 'Windows-1252')); // should be invalid var_dump(mb_detect_encoding($string, 'SJIS', true)); // should be valid var_dump(mb_detect_encoding($string, 'Windows-1252', true)); // should be invalid var_dump(mb_convert_encoding($string, 'UTF-8', 'SJIS')); // should correct var_dump(mb_convert_encoding($string, 'UTF-8', 'Windows-1252')); // should be wrong ``` Resulted in this output: ``` bool(true) bool(true) string(4) "SJIS" string(12) "Windows-1252" string(33) "パーティーへ行かないか" string(43) "ƒp[ƒeƒB[‚֍s‚©‚È‚¢‚©" ``` But I expected this output instead: ``` bool(true) bool(false) string(4) "SJIS" bool(false) string(33) "パーティーへ行かないか" string(46) "ƒp�[ƒeƒB�[‚Ö�s‚©‚È‚¢‚©" ``` [Online example here](https://3v4l.org/qg7E1) ### PHP Version PHP 8.1.27 ### Operating System CentOS 7

« previous php.bugs (#246606) next »