diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2006-08-23 21:52:13 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2006-08-23 21:52:13 +0000 |
| commit | a6bf50cf3e8d9d49516242947619c97806c30d56 (patch) | |
| tree | 0421e257b94e6310b316a596a963b0f48ed23727 /roundcubemail/program/include | |
| parent | 7c32c4b6105671dd5dd902a45d015e1437edeb02 (diff) | |
Fixed wrong usage of mbstring (Bug #1462439)
git-svn-id: https://svn.roundcube.net/trunk@324 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include')
| -rw-r--r-- | roundcubemail/program/include/main.inc | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc index 1a2b8c793..051d6e250 100644 --- a/roundcubemail/program/include/main.inc +++ b/roundcubemail/program/include/main.inc @@ -377,38 +377,14 @@ function load_gui() // set localization charset based on the given language function rcmail_set_locale($lang) { - global $OUTPUT, $MBSTRING, $MBSTRING_ENCODING; + global $OUTPUT, $MBSTRING; static $s_mbstring_loaded = NULL; // settings for mbstring module (by Tadashi Jokagi) - if ($s_mbstring_loaded===NULL) - { - if ($s_mbstring_loaded = extension_loaded("mbstring")) - { - $MBSTRING = TRUE; - if (function_exists("mb_mbstring_encodings")) - $MBSTRING_ENCODING = mb_mbstring_encodings(); - else - $MBSTRING_ENCODING = array("ISO-8859-1", "UTF-7", "UTF7-IMAP", "UTF-8", - "ISO-2022-JP", "EUC-JP", "EUCJP-WIN", - "SJIS", "SJIS-WIN"); - - $MBSTRING_ENCODING = array_map("strtoupper", $MBSTRING_ENCODING); - if (in_array("SJIS", $MBSTRING_ENCODING)) - $MBSTRING_ENCODING[] = "SHIFT_JIS"; - } - else - { - $MBSTRING = FALSE; - $MBSTRING_ENCODING = array(); - } - } - - if ($MBSTRING && function_exists("mb_language")) - { - if (!@mb_language(strtok($lang, "_"))) - $MBSTRING = FALSE; // unsupport language - } + if (is_null($s_mbstring_loaded)) + $MBSTRING = $s_mbstring_loaded = extension_loaded("mbstring"); + else + $MBSTRING = $s_mbstring_loaded = FALSE; $OUTPUT->set_charset(rcube_language_prop($lang, 'charset')); } @@ -868,22 +844,23 @@ function rcmail_message_cache_gc() // this function is not complete and not tested well function rcube_charset_convert($str, $from, $to=NULL) { - global $MBSTRING, $MBSTRING_ENCODING; + global $MBSTRING; $from = strtoupper($from); $to = $to==NULL ? strtoupper($GLOBALS['CHARSET']) : strtoupper($to); - if ($from==$to) + if ($from==$to || $str=='') return $str; - + // convert charset using mbstring module if ($MBSTRING) { $to = $to=="UTF-7" ? "UTF7-IMAP" : $to; $from = $from=="UTF-7" ? "UTF7-IMAP": $from; - - if (in_array($to, $MBSTRING_ENCODING) && in_array($from, $MBSTRING_ENCODING)) - return mb_convert_encoding($str, $to, $from); + + // return if convert succeeded + if (($out = mb_convert_encoding($str, $to, $from)) != '') + return $out; } // convert charset using iconv module |
