3v4l.org

run code in 500+ PHP versions simultaneously
<?php $differences = []; for ($_1 = 0; $_1 <= 0xff; $_1++) { $first_byte = chr($_1); for ($_2 = 0; $_2 <= 0xff; $_2++) { $second_byte = chr($_2); $two_bytes_sequence = $first_byte . $second_byte; assert( mb_convert_encoding($two_bytes_sequence, 'UTF-8', 'CP932') === mb_convert_encoding($two_bytes_sequence, 'UTF-8', 'SJIS-win') ); $cp932 = mb_convert_encoding($two_bytes_sequence, 'CP932', 'UCS-2'); $sjis_win = mb_convert_encoding($two_bytes_sequence, 'SJIS-win', 'UCS-2'); if ($cp932 !== $sjis_win) { $differences[] = [ sprintf('%02x', $_1), sprintf('%02x', $_2), mb_convert_encoding($two_bytes_sequence, 'UTF-8', 'UCS-2'), $cp932, array_map(fn ($byte) => sprintf('%02x', ord($byte)), str_split($cp932)), $sjis_win, array_map(fn ($byte) => sprintf('%02x', ord($byte)), str_split($sjis_win)), ]; } } } var_dump($differences);

preferences:
13.04 ms | 482 KiB | 4 Q