Ticket #1484730: roundcube-r955-charset.diff

File roundcube-r955-charset.diff, 7.3 kB (added by Javer, 12 months ago)

Patch for better native languages support, for example russian and others

  • config/main.inc.php.dist

    diff -ur roundcube.r955/config/main.inc.php.dist roundcube/config/main.inc.php.dist
    old new  
    120120// the default locale setting 
    121121$rcmail_config['locale_string'] = 'en'; 
    122122 
     123// the default locale charset 
     124$rcmail_config['locale_charset'] = 'ISO-8859-1'; 
     125 
    123126// use this format for short date display 
    124127$rcmail_config['date_short'] = 'D H:i'; 
    125128 
  • program/include/main.inc

    diff -ur roundcube.r955/program/include/main.inc roundcube/program/include/main.inc
    old new  
    141141  include_once('config/db.inc.php'); 
    142142  $conf = array_merge($conf, $rcmail_config); 
    143143 
     144  if (empty($conf['locale_charset'])) 
     145    $conf['locale_charset'] = 'ISO-8859-1'; 
     146 
    144147  if (empty($conf['log_dir'])) 
    145148    $conf['log_dir'] = $INSTALL_PATH.'logs'; 
    146149  else 
  • program/include/rcube_imap.inc

    diff -ur roundcube.r955/program/include/rcube_imap.inc roundcube/program/include/rcube_imap.inc
    old new  
    6565  var $search_string = ''; 
    6666  var $search_charset = ''; 
    6767  var $debug_level = 1; 
     68  var $charset = '';   
    6869  var $error_code = 0; 
    6970 
    7071 
     
    7879    $this->db = $db_conn; 
    7980    } 
    8081 
     82  function setCharset($charset) { 
     83    $this->charset = $charset; 
     84    } 
    8185 
    8286  /** 
    8387   * PHP 4 object constructor 
     
    889893      $results = $this->_search_index($mailbox, $search); 
    890894 
    891895      // try search with ISO charset (should be supported by server) 
    892       if (empty($results) && !empty($charset) && $charset!='ISO-8859-1') 
    893         $results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, 'ISO-8859-1'), 'ISO-8859-1'); 
     896      if (empty($results) && !empty($charset) && $charset!=$GLOBALS['CONFIG']['locale_charset']) 
     897        $results = $this->search($mbox_name, $criteria, rcube_charset_convert($str, $charset, $GLOBALS['CONFIG']['locale_charset']), $GLOBALS['CONFIG']['locale_charset']); 
    894898       
    895899      $this->set_search_set($criteria, $str, $results, $charset); 
    896900      return $results; 
     
    12291233        { 
    12301234        // assume ISO-8859-1 if no charset specified 
    12311235        if (empty($o_part->charset)) 
    1232           $o_part->charset = 'ISO-8859-1'; 
     1236          $o_part->charset = $GLOBALS['CONFIG']['locale_charset']; 
    12331237 
    12341238        $body = rcube_charset_convert($body, $o_part->charset); 
    12351239        } 
     
    22792283   */ 
    22802284  function decode_header($input, $remove_quotes=FALSE) 
    22812285    { 
    2282     $str = $this->decode_mime_string((string)$input); 
     2286    $str = $this->decode_mime_string((string)$input, !empty($this->charset) ? $this->charset : null ); 
    22832287    if ($str{0}=='"' && $remove_quotes) 
    22842288      $str = str_replace('"', '', $str); 
    22852289     
     
    23182322      } 
    23192323       
    23202324    // no encoding information, use fallback 
    2321     return rcube_charset_convert($input, !empty($fallback) ? $fallback : 'ISO-8859-1'); 
     2325    return rcube_charset_convert($input, !empty($fallback) ? $fallback : $GLOBALS['CONFIG']['locale_charset'] ); 
    23222326    } 
    23232327 
    23242328 
     
    23962400      return rcube_charset_convert($body, $ctype_param['charset']); 
    23972401 
    23982402    // defaults to what is specified in the class header 
    2399     return rcube_charset_convert($body,  'ISO-8859-1'); 
     2403    return rcube_charset_convert($body,  $GLOBALS['CONFIG']['locale_charset'] ); 
    24002404    } 
    24012405 
    24022406 
  • program/lib/Mail/mime.php

    diff -ur roundcube.r955/program/lib/Mail/mime.php roundcube/program/lib/Mail/mime.php
    old new  
    182182                                     'text_encoding' => '7bit', 
    183183                                     'html_encoding' => 'quoted-printable', 
    184184                                     '7bit_wrap'     => 998, 
    185                                      'html_charset'  => 'ISO-8859-1', 
    186                                      'text_charset'  => 'ISO-8859-1', 
    187                                      'head_charset'  => 'ISO-8859-1' 
     185                                     'html_charset'  => $GLOBALS['CONFIG']['locale_charset'], 
     186                                     'text_charset'  => $GLOBALS['CONFIG']['locale_charset'], 
     187                                     'head_charset'  => $GLOBALS['CONFIG']['locale_charset'] 
    188188                                    ); 
    189189    } 
    190190 
     
    527527        $params['encoding']     = $value['encoding']; 
    528528        if ($value['disposition'] != "inline") { 
    529529            $fname = array("fname" => $value['name']); 
    530             $fname_enc = $this->_encodeHeaders($fname, array('head_charset' => $value['charset'] ? $value['charset'] : 'iso-8859-1')); 
     530            $fname_enc = $this->_encodeHeaders($fname, array('head_charset' => $value['charset'] ? $value['charset'] : $GLOBALS['CONFIG']['locale_charset'])); 
    531531            $params['dfilename'] = $fname_enc['fname']; 
    532532        } 
    533533        if ($value['charset']) { 
  • program/lib/utf8.class.php

    diff -ur roundcube.r955/program/lib/utf8.class.php roundcube/program/lib/utf8.class.php
    old new  
    3838// Adapted to fit RoundCube 
    3939define("UTF8_MAP_DIR", "program/lib/encoding"); 
    4040$utf8_maps = array( 
     41  "KOI8-R" => UTF8_MAP_DIR . "/KOI8R.map", 
     42  "KOI8_R" => UTF8_MAP_DIR . "/KOI8R.map", 
     43  "KOI8R"  => UTF8_MAP_DIR . "/KOI8R.map", 
    4144  "CP1250" => UTF8_MAP_DIR . "/CP1250.map", 
    4245  "CP1251" => UTF8_MAP_DIR . "/CP1251.map", 
    4346  "CP1252" => UTF8_MAP_DIR . "/CP1252.map", 
     
    6467//Class definition 
    6568Class utf8{ 
    6669 
    67   var $charset = "ISO-8859-1"; 
     70  var $charset = ""; 
    6871  var $ascMap = array(); 
    6972  var $utfMap = array(); 
    7073 
    7174  // made PHP5 capable by RoundCube 
    72   function __construct($charset="ISO-8859-1"){ 
    73     $this->loadCharset($charset); 
     75  function __construct($charset=""){ 
     76     $this->charset = $GLOBALS['CONFIG']['locale_charset']; 
     77     if(empty($charset)) $charset = $this->charset; 
     78     $this->loadCharset($charset); 
    7479  } 
    7580   
    7681  //Constructor 
    77   function utf8($charset="ISO-8859-1"){ 
     82  function utf8($charset=""){ 
    7883    $this->__construct($charset); 
    7984  } 
    8085 
  • program/steps/mail/func.inc

    diff -ur roundcube.r955/program/steps/mail/func.inc roundcube/program/steps/mail/func.inc
    old new  
    229229     
    230230    $out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : ''); 
    231231     
     232    $IMAP->setCharset($header->charset); 
     233     
    232234    // format each col 
    233235    foreach ($a_show_cols as $col) 
    234236      { 
     
    317319    if (empty($header)) 
    318320      continue; 
    319321 
     322    $IMAP->setCharset($header->charset); 
     323 
    320324    // format each col; similar as in rcmail_message_list() 
    321325    foreach ($a_show_cols as $col) 
    322326      { 
     
    815819   
    816820  $header_count = 0; 
    817821   
     822 
     823  $IMAP->setCharset($headers['charset']); 
     824 
    818825  // allow the following attributes to be added to the <table> tag 
    819826  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
    820827  $out = '<table' . $attrib_str . ">\n";