Changeset 6088 in subversion


Ignore:
Timestamp:
Apr 15, 2012 4:51:54 AM (13 months ago)
Author:
alec
Message:
  • Small optimizations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_charset.php

    r6085 r6088  
    9494     * @return string The validated charset name 
    9595     */ 
    96     public static function parse($input) 
     96    public static function parse_charset($input) 
    9797    { 
    9898        static $charsets = array(); 
     
    179179    { 
    180180        static $iconv_options   = null; 
    181         static $mbstring_loaded = null; 
    182181        static $mbstring_list   = null; 
    183182        static $conv            = null; 
    184183 
    185         $to   = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse($to); 
    186         $from = self::parse($from); 
     184        $to   = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse_charset($to); 
     185        $from = self::parse_charset($from); 
    187186 
    188187        if ($from == $to || empty($str) || empty($from)) { 
     
    190189        } 
    191190 
    192         // convert charset using iconv module 
    193         if (function_exists('iconv') && $from != 'UTF7-IMAP' && $to != 'UTF7-IMAP') { 
    194             if ($iconv_options === null) { 
     191        if ($iconv_options === null) { 
     192            if (function_exists('iconv')) { 
    195193                // ignore characters not available in output charset 
    196194                $iconv_options = '//IGNORE'; 
     
    200198                } 
    201199            } 
    202  
     200        } 
     201 
     202        // convert charset using iconv module 
     203        if ($iconv_options !== null && $from != 'UTF7-IMAP' && $to != 'UTF7-IMAP') { 
    203204            // throw an exception if iconv reports an illegal character in input 
    204205            // it means that input string has been truncated 
     
    216217        } 
    217218 
    218         if ($mbstring_loaded === null) { 
    219             $mbstring_loaded = extension_loaded('mbstring'); 
    220         } 
    221  
    222         // convert charset using mbstring module 
    223         if ($mbstring_loaded) { 
    224             $aliases['WINDOWS-1257'] = 'ISO-8859-13'; 
    225  
    226             if ($mbstring_list === null) { 
     219        if ($mbstring_list === null) { 
     220            if (extension_loaded('mbstring')) { 
    227221                $mbstring_list = mb_list_encodings(); 
    228222                $mbstring_list = array_map('strtoupper', $mbstring_list); 
    229223            } 
     224        } 
     225 
     226        // convert charset using mbstring module 
     227        if ($mbstring_list !== null) { 
     228            $aliases['WINDOWS-1257'] = 'ISO-8859-13'; 
    230229 
    231230            $mb_from = $aliases[$from] ? $aliases[$from] : $from; 
Note: See TracChangeset for help on using the changeset viewer.