3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tai = '鯛'; // A kind of fish, included in JIS X 0208 $kasago = '鮋'; // A kind of fish, included in JIS X 0212, not included in JIS X 0213. $hokke = '𩸽'; // A kind of fish, included in JIS X 0213, not included in JIS X 0212. echo "# mb_convert_encoding\n"; $tai_iso2022jp = mb_convert_encoding($tai, 'ISO-2022-JP', 'UTF-8'); $tai_jis = mb_convert_encoding($tai, 'JIS', 'UTF-8'); $tai_iso2022jp_2004 = mb_convert_encoding($tai, 'ISO-2022-JP-2004', 'UTF-8'); echo "Convert tai to ISO-2022-JP : " . bin2hex($tai_iso2022jp) . "\n"; echo "Convert tai to JIS : " . bin2hex($tai_jis) . "\n"; echo "Convert tai to ISO-2022-JP-2004 : " . bin2hex($tai_iso2022jp_2004) . "\n"; echo "\n"; $kasago_iso2022jp = mb_convert_encoding($kasago, 'ISO-2022-JP', 'UTF-8'); $kasago_jis = mb_convert_encoding($kasago, 'JIS', 'UTF-8'); $kasago_iso2022jp_2004 = mb_convert_encoding($kasago, 'ISO-2022-JP-2004', 'UTF-8'); echo "Convert kasago to ISO-2022-JP : " . bin2hex($kasago_iso2022jp) . "\n"; echo "Convert kasago to JIS : " . bin2hex($kasago_jis) . "\n"; echo "Convert kasago to ISO-2022-JP-2004: " . bin2hex($kasago_iso2022jp_2004) . "\n"; echo "\n"; $hokke_iso2022jp = mb_convert_encoding($hokke, 'ISO-2022-JP', 'UTF-8'); $hokke_jis = mb_convert_encoding($hokke, 'JIS', 'UTF-8'); $hokke_iso2022jp_2004 = mb_convert_encoding($hokke, 'ISO-2022-JP-2004', 'UTF-8'); echo "Convert hokke to ISO-2022-JP : " . bin2hex($hokke_iso2022jp) . "\n"; echo "Convert hokke to JIS : " . bin2hex($hokke_jis) . "\n"; echo "Convert hokke to ISO-2022-JP-2004 : " . bin2hex($hokke_iso2022jp_2004) . "\n"; echo "\n"; echo "# mb_check_encoding\n"; $tai_0208 = mb_convert_encoding($tai, 'ISO-2022-JP', 'UTF-8'); // 1b244242641b2842 $kasago_0212 = mb_convert_encoding($kasago, 'JIS', 'UTF-8'); // 1b2428446a591b2842 $hokke_0213 = mb_convert_encoding($hokke, 'ISO-2022-JP-2004', 'UTF-8'); // 1b2428507d4c1b2842 echo "Tai written in JIS X 0208 : " . bin2hex($tai_0208) . "\n"; echo "Hokke written in JIS X 0212 : " . bin2hex($kasago_0212) . "\n"; echo "Kasago written in JIS X 0213: " . bin2hex($hokke_0213) . "\n"; echo "\n"; echo "Tai written in JIS X 0208\n"; echo "ISO-2022-JP : "; var_dump(mb_check_encoding($tai_0208, 'iso-2022-jp')); // true is expected echo "JIS : "; var_dump(mb_check_encoding($tai_0208, 'jis')); // true is expected echo "ISO-2022-JP-2004: "; var_dump(mb_check_encoding($tai_0208, 'iso-2022-jp-2004')); // true is expected echo "\n"; echo "Hokke written in JIS X 0212\n"; echo "ISO-2022-JP : "; var_dump(mb_check_encoding($kasago_0212, 'iso-2022-jp')); // false is expected echo "JIS : "; var_dump(mb_check_encoding($kasago_0212, 'jis')); // true is expected echo "ISO-2022-JP-2004: "; var_dump(mb_check_encoding($kasago_0212, 'iso-2022-jp-2004')); // false is expected echo "\n"; echo "Kasago written in JIS X 0213\n"; echo "ISO-2022-JP : "; var_dump(mb_check_encoding($hokke_0213, 'iso-2022-jp')); // false is expected echo "JIS : "; var_dump(mb_check_encoding($hokke_0213, 'jis')); // false is expected echo "ISO-2022-JP-2004: "; var_dump(mb_check_encoding($hokke_0213, 'iso-2022-jp-2004')); // true is expected
Output for 8.1.18 - 8.1.33, 8.2.5 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14
# mb_convert_encoding Convert tai to ISO-2022-JP : 1b244242641b2842 Convert tai to JIS : 1b244242641b2842 Convert tai to ISO-2022-JP-2004 : 1b24285142641b2842 Convert kasago to ISO-2022-JP : 3f Convert kasago to JIS : 1b2428446a591b2842 Convert kasago to ISO-2022-JP-2004: 3f Convert hokke to ISO-2022-JP : 3f Convert hokke to JIS : 3f Convert hokke to ISO-2022-JP-2004 : 1b2428507d4c1b2842 # mb_check_encoding Tai written in JIS X 0208 : 1b244242641b2842 Hokke written in JIS X 0212 : 1b2428446a591b2842 Kasago written in JIS X 0213: 1b2428507d4c1b2842 Tai written in JIS X 0208 ISO-2022-JP : bool(true) JIS : bool(true) ISO-2022-JP-2004: bool(true) Hokke written in JIS X 0212 ISO-2022-JP : bool(false) JIS : bool(true) ISO-2022-JP-2004: bool(false) Kasago written in JIS X 0213 ISO-2022-JP : bool(false) JIS : bool(false) ISO-2022-JP-2004: bool(true)
Output for 8.1.0 - 8.1.17, 8.2.0 - 8.2.4
# mb_convert_encoding Convert tai to ISO-2022-JP : 1b244242641b2842 Convert tai to JIS : 1b244242641b2842 Convert tai to ISO-2022-JP-2004 : 1b24285142641b2842 Convert kasago to ISO-2022-JP : 3f Convert kasago to JIS : 1b2428446a591b2842 Convert kasago to ISO-2022-JP-2004: 3f Convert hokke to ISO-2022-JP : 3f Convert hokke to JIS : 3f Convert hokke to ISO-2022-JP-2004 : 1b2428507d4c1b2842 # mb_check_encoding Tai written in JIS X 0208 : 1b244242641b2842 Hokke written in JIS X 0212 : 1b2428446a591b2842 Kasago written in JIS X 0213: 1b2428507d4c1b2842 Tai written in JIS X 0208 ISO-2022-JP : bool(true) JIS : bool(true) ISO-2022-JP-2004: bool(true) Hokke written in JIS X 0212 ISO-2022-JP : bool(true) JIS : bool(true) ISO-2022-JP-2004: bool(false) Kasago written in JIS X 0213 ISO-2022-JP : bool(false) JIS : bool(false) ISO-2022-JP-2004: bool(true)
Output for 8.0.1 - 8.0.30
# mb_convert_encoding Convert tai to ISO-2022-JP : 1b244242641b2842 Convert tai to JIS : 1b244242641b2842 Convert tai to ISO-2022-JP-2004 : 1b24285142641b2842 Convert kasago to ISO-2022-JP : 3f Convert kasago to JIS : 1b2428446a591b2842 Convert kasago to ISO-2022-JP-2004: 3f Convert hokke to ISO-2022-JP : 3f Convert hokke to JIS : 3f Convert hokke to ISO-2022-JP-2004 : 1b2428507d4c1b2842 # mb_check_encoding Tai written in JIS X 0208 : 1b244242641b2842 Hokke written in JIS X 0212 : 1b2428446a591b2842 Kasago written in JIS X 0213: 1b2428507d4c1b2842 Tai written in JIS X 0208 ISO-2022-JP : bool(true) JIS : bool(true) ISO-2022-JP-2004: bool(false) Hokke written in JIS X 0212 ISO-2022-JP : bool(false) JIS : bool(true) ISO-2022-JP-2004: bool(false) Kasago written in JIS X 0213 ISO-2022-JP : bool(false) JIS : bool(false) ISO-2022-JP-2004: bool(true)

preferences:
93.04 ms | 412 KiB | 5 Q