Template::ChangeCharset PHP Method

ChangeCharset() public static method

public static ChangeCharset ( $p_oFile, $p_dFile, $p_type, $p_charset )
    public static function ChangeCharset($p_oFile, $p_dFile, $p_type, $p_charset)
    {
        if (strncmp($p_type, 'text', 4) == 0) {
            $origFile = $p_dFile . '.orig';
            $success = rename($p_oFile, $origFile);
            if ($success) {
                $command = 'iconv -f ' . escapeshellarg($p_charset) . ' -t UTF-8 ' . escapeshellarg($origFile) . ' > ' . escapeshellarg($p_dFile);
                system($command, $status);
                if ($status == 0) {
                    $success = unlink($origFile);
                } else {
                    $success = false;
                    unlink($p_dFile);
                    return new PEAR_Error("Unable to convert the character set of the file.");
                }
            } else {
                return new PEAR_Error(camp_get_error_message(CAMP_ERROR_CREATE_FILE, $origFile), CAMP_ERROR_CREATE_FILE);
            }
        }
        return $success;
    }