3v4l.org

run code in 300+ PHP versions simultaneously
<?php $utf8_str = "苫小牧"; echo 'UTF-8 as hex: ' . bin2hex($utf8_str) . PHP_EOL; $sjis_str = mb_convert_encoding($utf8_str, 'SJIS', 'UTF-8'); echo 'SJIS as hex: ' . bin2hex($sjis_str) . PHP_EOL; // detect encoding of $str $encode = mb_detect_encoding($sjis_str, 'EUC-JP,UTF-8,SJIS'); echo 'Detected encoding: ' . $encode . PHP_EOL; $euc_str = mb_convert_encoding( $sjis_str, "EUC-JP",$encode); echo 'EUC as hex: ' . bin2hex($euc_str) . PHP_EOL;

preferences:
26.6 ms | 406 KiB | 5 Q