Thomas Bruederli
2015-09-14 db390a27fbab2e753bd17ed11cdc3be9d84612f7
program/lib/Roundcube/rcube_charset.php
@@ -1,6 +1,6 @@
<?php
/*
/**
 +-----------------------------------------------------------------------+
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
@@ -77,7 +77,6 @@
    {
        throw new ErrorException($errstr, 0, $errno);
    }
    /**
     * Parse and validate charset name string (see #1485758).
@@ -158,7 +157,6 @@
        return $result;
    }
    /**
     * Convert a string from one charset to another.
@@ -273,7 +271,7 @@
                return utf8_encode($str);
            }
            else  {
                user_error("No suitable function found for UTF-8 encoding", E_USER_WARNING);
                trigger_error("No suitable function found for UTF-8 encoding");
            }
        }
@@ -289,7 +287,7 @@
                return utf8_decode($str);
            }
            else {
                user_error("No suitable function found for UTF-8 decoding", E_USER_WARNING);
                trigger_error("No suitable function found for UTF-8 decoding");
            }
        }
@@ -297,13 +295,12 @@
        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)
    {
@@ -357,13 +354,12 @@
        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)
    {
@@ -388,7 +384,6 @@
        return $dec;
    }
    /**
     * Convert the data ($str) from RFC 2060's UTF-7 to UTF-8.
@@ -497,7 +492,6 @@
        return $p;
    }
    /**
     * Convert the data ($str) from UTF-8 to RFC 2060's UTF-7.
@@ -629,7 +623,6 @@
        return $p;
    }
    /**
     * A method to guess character set of a string.
     *
@@ -729,7 +722,6 @@
        return $failover;
    }
    /**
     * Removes non-unicode characters from input.
     *
@@ -753,7 +745,7 @@
        // 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);
@@ -789,34 +781,32 @@
            // 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;
    }
}