| | |
| | | <?php |
| | | |
| | | /* |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | |
| | | { |
| | | throw new ErrorException($errstr, 0, $errno); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parse and validate charset name string (see #1485758). |
| | |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Convert a string from one charset to another. |
| | |
| | | return $str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Converts string from standard UTF-7 (RFC 2152) to UTF-8. |
| | | * |
| | | * @param string Input string (UTF-7) |
| | | * @param string $str Input string (UTF-7) |
| | | * |
| | | * @return string Converted string (UTF-8) |
| | | * @return string Converted string (UTF-8) |
| | | */ |
| | | public static function utf7_to_utf8($str) |
| | | { |
| | |
| | | return $res; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Converts string from UTF-16 to UTF-8 (helper for utf-7 to utf-8 conversion) |
| | | * |
| | | * @param string Input string |
| | | * @param string $str Input string |
| | | * |
| | | * @return string The converted string |
| | | * @return string The converted string |
| | | */ |
| | | public static function utf16_to_utf8($str) |
| | | { |
| | |
| | | |
| | | return $dec; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Convert the data ($str) from RFC 2060's UTF-7 to UTF-8. |
| | |
| | | |
| | | return $p; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Convert the data ($str) from UTF-8 to RFC 2060's UTF-7. |
| | |
| | | return $p; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * A method to guess character set of a string. |
| | | * |
| | |
| | | return $failover; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Removes non-unicode characters from input. |
| | | * |
| | |
| | | |
| | | // iconv/mbstring are much faster (especially with long strings) |
| | | if (function_exists('mb_convert_encoding')) { |
| | | $msch = mb_substitute_character('none'); |
| | | $msch = mb_substitute_character(); |
| | | mb_substitute_character('none'); |
| | | $res = mb_convert_encoding($input, 'UTF-8', 'UTF-8'); |
| | | mb_substitute_character($msch); |
| | |
| | | |
| | | // 1-byte character |
| | | if ($ord <= 0x7F) { |
| | | if ($seq) { |
| | | if ($seq !== '') { |
| | | $out .= preg_match($regexp, $seq) ? $seq : ''; |
| | | $seq = ''; |
| | | } |
| | | $seq = ''; |
| | | |
| | | $out .= $chr; |
| | | } |
| | | // first (or second) byte of multibyte sequence |
| | | // first byte of multibyte sequence |
| | | else if ($ord >= 0xC0) { |
| | | if (strlen($seq) > 1) { |
| | | if ($seq !== '') { |
| | | $out .= preg_match($regexp, $seq) ? $seq : ''; |
| | | $seq = ''; |
| | | } |
| | | else if ($seq && ord($seq) < 0xC0) { |
| | | $seq = ''; |
| | | } |
| | | $seq .= $chr; |
| | | |
| | | $seq = $chr; |
| | | } |
| | | // next byte of multibyte sequence |
| | | else if ($seq) { |
| | | else if ($seq !== '') { |
| | | $seq .= $chr; |
| | | } |
| | | } |
| | | |
| | | if ($seq) { |
| | | if ($seq !== '') { |
| | | $out .= preg_match($regexp, $seq) ? $seq : ''; |
| | | } |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | } |