Example #1
1
function jcode_convert_encoding($str, $to, $from = '')
{
    $jc_to = _check_encoding($to);
    $jc_from = _check_encoding($from);
    if ($jc_from == 0) {
        $jc_from = AutoDetect($str);
    }
    if ($jc_to == 4) {
        global $table_jis_utf8;
        include_once dirname(__FILE__) . '/code_table.jis2ucs';
    }
    if ($jc_from == 4) {
        global $table_utf8_jis;
        include_once dirname(__FILE__) . '/code_table.ucs2jis';
    }
    return JcodeConvert($str, $jc_from, $jc_to);
}
Example #2
0
function JcodeConvert(&$str, $from, $to)
{
    //0:AUTO DETECT
    //1:EUC-JP
    //2:Shift_JIS
    //3:ISO-2022-JP(JIS)
    //4:UTF-8
    if ($from == 0) {
        $from = AutoDetect($str);
    }
    if ($from == 1 && $to == 2) {
        return EUCtoSJIS($str);
    }
    if ($from == 1 && $to == 3) {
        return EUCtoJIS($str);
    }
    if ($from == 1 && $to == 4) {
        return EUCtoUTF8($str);
    }
    if ($from == 2 && $to == 1) {
        return SJIStoEUC($str);
    }
    if ($from == 2 && $to == 3) {
        return SJIStoJIS($str);
    }
    if ($from == 2 && $to == 4) {
        return SJIStoUTF8($str);
    }
    if ($from == 3 && $to == 1) {
        return JIStoEUC($str);
    }
    if ($from == 3 && $to == 2) {
        return JIStoSJIS($str);
    }
    if ($from == 3 && $to == 4) {
        return JIStoUTF8($str);
    }
    if ($from == 4 && $to == 1) {
        return UTF8toEUC($str);
    }
    if ($from == 4 && $to == 2) {
        return UTF8toSJIS($str);
    }
    if ($from == 4 && $to == 3) {
        return UTF8toJIS($str);
    }
    return $str;
}
Example #3
0
function mb_detect_encoding($str)
{
    $encode = AutoDetect($str);
    if ($encode == 0) {
        $encode = "ASCII";
    } elseif ($encode == 1) {
        $encode = "EUC-JP";
    } elseif ($encode == 2) {
        $encode = "SJIS";
    } elseif ($encode == 3) {
        $encode = "ISO-2022-JP";
    } elseif ($encode == 4) {
        $encode = "UTF-8";
    } elseif ($encode == 5) {
        $encode = "";
    }
    return $encode;
}
Example #4
0
 function mb_detect_encoding($str, $encoding_list = '')
 {
     static $codes = array(0 => 'ASCII', 1 => 'EUC-JP', 2 => 'SJIS', 3 => 'JIS', 4 => 'UTF-8');
     // 注: $encoding_listは使用しない。
     $code = AutoDetect($str);
     if (!isset($codes[$code])) {
         $code = 0;
     }
     // oh ;(
     return $codes[$code];
 }