Changeset b8e65ce3 in github


Ignore:
Timestamp:
Aug 10, 2007 12:38:29 PM (6 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
8810b6db
Parents:
e715986
Message:

Fix charset converting issues with iconv and mbstring

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    re715986 rb8e65ce3  
    1010- Make autocomplete for loginform configurable by the skin template 
    1111- Fix compose function from address book (closes #1484426) 
     12- Added //IGNORE to iconv call (patch #1484420, closes #1484023) 
     13- Check if mbstring supports charset (#1484290 and #1484292) 
     14- Prefer iconv over mbstring (as suggested in #1484292) 
    1215- Updated Simplified Chinese localization 
    1316- Added Ukrainian translation 
  • program/include/main.inc

    r31d9efd rb8e65ce3  
    473473   
    474474  // settings for mbstring module (by Tadashi Jokagi) 
    475   if (is_null($s_mbstring_loaded)) 
    476     $MBSTRING = $s_mbstring_loaded = extension_loaded("mbstring"); 
    477   else 
     475  if (is_null($s_mbstring_loaded) && ($s_mbstring_loaded = extension_loaded("mbstring"))) 
     476  { 
     477    $MBSTRING = array(); 
     478    foreach (mb_list_encodings() as $charset) 
     479      $MBSTRING[strtoupper($charset)] = strtoupper($charset); 
     480     
     481    // add some alias charsets 
     482    $MBSTRING['UTF-7'] = "UTF7-IMAP"; 
     483    $MBSTRING['WINDOWS-1257'] = "ISO-8859-13"; 
     484  } 
     485  else if (is_null($s_mbstring_loaded)) 
    478486    $MBSTRING = $s_mbstring_loaded = FALSE; 
    479487     
     
    10501058  { 
    10511059  global $MBSTRING; 
     1060  static $mb_encodings; 
    10521061 
    10531062  $from = strtoupper($from); 
     
    10571066    return $str; 
    10581067 
     1068  // convert charset using iconv module   
     1069  if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') 
     1070    return iconv($from, $to . "//IGNORE", $str); 
     1071 
    10591072  // convert charset using mbstring module   
    1060   if ($MBSTRING) 
    1061     { 
    1062     $to = $to=="UTF-7" ? "UTF7-IMAP" : $to; 
    1063     $from = $from=="UTF-7" ? "UTF7-IMAP": $from; 
    1064  
     1073  if ($MBSTRING && ($mbfrom = $MBSTRING[$from]) && ($mbto = $MBSTRING[$to])) 
     1074    { 
    10651075    // return if convert succeeded 
    1066     if (($out = mb_convert_encoding($str, $to, $from)) != '') 
     1076    if (($out = mb_convert_encoding($str, $mbto, $mbfrom)) != '') 
    10671077      return $out; 
    10681078    } 
    1069  
    1070   // convert charset using iconv module   
    1071   if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') 
    1072     return iconv($from, $to, $str); 
    10731079 
    10741080  $conv = new utf8(); 
Note: See TracChangeset for help on using the changeset viewer.