| | |
| | | $to = $to==NULL ? strtoupper(RCMAIL_CHARSET) : strtoupper($to); |
| | | $error = false; $conv = null; |
| | | |
| | | if ($from==$to || $str=='' || empty($from)) |
| | | # RFC1642 |
| | | if ($from == 'UNICODE-1-1-UTF-7') |
| | | $from = 'UTF-7'; |
| | | if ($to == 'UNICODE-1-1-UTF-7') |
| | | $to = 'UTF-7'; |
| | | |
| | | if ($from == $to || empty($str) || empty($from)) |
| | | return $str; |
| | | |
| | | $aliases = array( |
| | |
| | | return $_iconv; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (is_null($mbstring_loaded)) |
| | | $mbstring_loaded = extension_loaded('mbstring'); |
| | |
| | | return $out; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | # try to convert with custom classes |
| | | if (class_exists('utf8')) |
| | | $conv = new utf8(); |
| | | |
| | |
| | | if ($from == 'UTF-7') { |
| | | if ($_str = utf7_to_utf8($str)) |
| | | $str = $_str; |
| | | else |
| | | $error = true; |
| | | } |
| | | else if (($from == 'ISO-8859-1') && function_exists('utf8_encode')) { |
| | | $str = utf8_encode($str); |
| | |
| | | $conv->loadCharset($from); |
| | | $str = $conv->strToUtf8($str); |
| | | } |
| | | else if ($from != 'UTF-8') {} |
| | | else if ($from != 'UTF-8') |
| | | $error = true; |
| | | |
| | | // encode string for output |
| | |
| | | 'code' => 500, |
| | | 'type' => 'php', |
| | | 'file' => __FILE__, |
| | | 'message' => "Could not convert string charset. Make sure iconv is installed or lib/utf8.class is available" |
| | | 'message' => "Could not convert string from $from to $to. Make sure iconv is installed or lib/utf8.class is available" |
| | | ), true, false); |
| | | |
| | | $convert_warning = true; |