3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jis_bytes = '1b244224221b2842'; // 'あ' in ISO-2022-JP $jis_bytes_without_esc = '1b24422422'; // 'あ' in ISO-2022-JP without escape sequence var_dump(mb_check_encoding(hex2bin($jis_bytes), 'JIS')); var_dump(mb_check_encoding(hex2bin($jis_bytes_without_esc), 'JIS'));
Output for 8.0.1 - 8.0.30, 8.1.18 - 8.1.33, 8.2.5 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
bool(true) bool(false)
Output for 8.1.0 - 8.1.17, 8.2.0 - 8.2.4
bool(true) bool(true)

preferences:
93.9 ms | 407 KiB | 5 Q