PHPスクリプト/mb_convert_encoding()

PHPスクリプト

mb_convert_encoding

文字コードの変換を行なう

書式

mb_convert_encoding(文字列, "変換文字コード", "変換元文字コード")

変数$strをEUC-JPに変換

<?PHP
$str=mb_convert_encoding($str, "EUC-JP", "auto");
?>

変数$strをUTF-8からEUC-JPに変換

<?PHP
$str=mb_convert_encoding($str, "EUC-JP", "UTF-8");
?>

Unable to detect character encoding in

"auto"で指定すると、こんなエラーが出る場合があります。

下記のようにするか

mb_convert_encoding($word, "SJIS", "ASCII,JIS,UTF-8,EUC-JP,SJIS");

このようにして回避

mb_language("Japanese");.
mb_convert_encoding($word, "SJIS", "auto");