Example #1
0
function doCjUtfAndGbk($str, $phome = 0)
{
    //正常编码
    if ($phome == 0) {
        return $str;
    }
    if ($phome == 1) {
        $str = DoIconvVal("UTF8", "GB2312", $str);
    } elseif ($phome == 2) {
        $str = DoIconvVal("UTF8", "BIG5", $str);
    } elseif ($phome == 3) {
        $str = DoIconvVal("BIG5", "GB2312", $str);
    } elseif ($phome == 4) {
        $str = DoIconvVal("GB2312", "BIG5", $str);
    } elseif ($phome == 5) {
        $str = DoIconvVal("UNICODE", "GB2312", $str);
    } elseif ($phome == 6) {
        $str = DoIconvVal("UNICODE", "BIG5", $str);
    } elseif ($phome == 7) {
        $str = DoIconvVal("GB2312", "UTF8", $str);
    } elseif ($phome == 8) {
        $str = DoIconvVal("BIG5", "UTF8", $str);
    } elseif ($phome == 9) {
        $str = DoIconvVal("UNICODE", "UTF8", $str);
    } else {
    }
    return $str;
}
Example #2
0
function LoadInTempChangeChar($tempchar, $text)
{
    global $ecms_config;
    @(include_once ECMS_PATH . DASHBOARD . '/class/EmpireCMS_version.php');
    if ($tempchar == 'GB2312') {
        if ($ecms_config['sets']['pagechar'] == 'gb2312') {
            return $text;
        }
        if ($ecms_config['sets']['pagechar'] == 'utf-8') {
            if (EmpireCMS_CHARVER == 'TC-UTF-8') {
                $text = DoIconvVal("GB2312", "BIG5", $text, 1);
                $text = DoIconvVal("BIG5", "UTF8", $text);
            } else {
                $text = DoIconvVal("GB2312", "UTF8", $text, 1);
            }
            $text = preg_replace(array('/charset=gbk/i', '/charset=gb2312/i'), array('charset=utf-8', 'charset=utf-8'), $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'big5') {
            $text = DoIconvVal("GB2312", "BIG5", $text, 1);
            $text = preg_replace(array('/charset=gbk/i', '/charset=gb2312/i'), array('charset=big5', 'charset=big5'), $text);
        }
    } elseif ($tempchar == 'UTF8') {
        if ($ecms_config['sets']['pagechar'] == 'utf-8' && EmpireCMS_CHARVER == 'UTF-8') {
            return $text;
        }
        if ($ecms_config['sets']['pagechar'] == 'gb2312') {
            $text = DoIconvVal("UTF8", "GB2312", $text, 1);
            $text = preg_replace('/charset=utf-8/i', 'charset=gb2312', $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'big5') {
            $text = DoIconvVal("UTF8", "GB2312", $text, 1);
            $text = DoIconvVal("GB2312", "BIG5", $text);
            $text = preg_replace('/charset=utf-8/i', 'charset=big5', $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'utf-8') {
            $text = DoIconvVal("UTF8", "GB2312", $text, 1);
            $text = DoIconvVal("GB2312", "BIG5", $text);
            $text = DoIconvVal("BIG5", "UTF8", $text);
        }
    } elseif ($tempchar == 'BIG5') {
        if ($ecms_config['sets']['pagechar'] == 'big5') {
            return $text;
        }
        if ($ecms_config['sets']['pagechar'] == 'gb2312') {
            $text = DoIconvVal("BIG5", "GB2312", $text, 1);
            $text = preg_replace('/charset=big5/i', 'charset=gb2312', $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'utf-8') {
            if (EmpireCMS_CHARVER == 'UTF-8') {
                $text = DoIconvVal("BIG5", "GB2312", $text, 1);
                $text = DoIconvVal("GB2312", "UTF8", $text);
            } else {
                $text = DoIconvVal("BIG5", "UTF8", $text, 1);
            }
            $text = preg_replace('/charset=big5/i', 'charset=utf-8', $text);
        }
    } elseif ($tempchar == 'TCUTF8') {
        if ($ecms_config['sets']['pagechar'] == 'utf-8' && EmpireCMS_CHARVER == 'TC-UTF-8') {
            return $text;
        }
        if ($ecms_config['sets']['pagechar'] == 'gb2312') {
            $text = DoIconvVal("UTF8", "BIG5", $text, 1);
            $text = DoIconvVal("BIG5", "GB2312", $text);
            $text = preg_replace('/charset=utf-8/i', 'charset=gb2312', $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'big5') {
            $text = DoIconvVal("UTF8", "BIG5", $text, 1);
            $text = preg_replace('/charset=utf-8/i', 'charset=big5', $text);
        } elseif ($ecms_config['sets']['pagechar'] == 'utf-8') {
            $text = DoIconvVal("UTF8", "BIG5", $text, 1);
            $text = DoIconvVal("BIG5", "GB2312", $text);
            $text = DoIconvVal("GB2312", "UTF8", $text);
        }
    }
    return $text;
}