| | |
| | | * @param int Level of the error |
| | | * @param string Error message |
| | | */ |
| | | public function error_handler($errno, $errstr) |
| | | public static function error_handler($errno, $errstr) |
| | | { |
| | | throw new ErrorException($errstr, 0, $errno); |
| | | } |
| | |
| | | * Sometimes charset string is malformed, there are also charset aliases |
| | | * but we need strict names for charset conversion (specially utf8 class) |
| | | * |
| | | * @param string Input charset name |
| | | * @param string $input Input charset name |
| | | * |
| | | * @return string The validated charset name |
| | | */ |
| | |
| | | static $mbstring_list = null; |
| | | static $conv = null; |
| | | |
| | | $to = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse($to); |
| | | $to = empty($to) ? strtoupper(RCMAIL_CHARSET) : $to; |
| | | $from = self::parse($from); |
| | | |
| | | // It is a common case when UTF-16 charset is used with US-ASCII content (#1488654) |
| | | // In that case we can just skip the conversion (use UTF-8) |
| | | if ($from == 'UTF-16' && !preg_match('/[^\x00-\x7F]/', $str)) { |
| | | $from = 'UTF-8'; |
| | | } |
| | | |
| | | if ($from == $to || empty($str) || empty($from)) { |
| | | return $str; |
| | |
| | | if ($from == 'UTF-8') { |
| | | // @TODO: we need a function for UTF-7 (RFC2152) conversion |
| | | if ($to == 'UTF7-IMAP' || $to == 'UTF-7') { |
| | | if ($_str = utf8_to_utf7imap($str)) { |
| | | if ($_str = self::utf8_to_utf7imap($str)) { |
| | | return $_str; |
| | | } |
| | | } |