protected function convertCharset($from, $to, $str)
    {
        if (function_exists('mb_convert_encoding')) {
            return mb_convert_encoding($str, $to, $from);
        } else if (function_exists('iconv')) {
            return iconv($from, $to, $str);
        }
        return $str;
    }