summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2006-02-20 23:29:14 +0000
committerthomascube <thomas@roundcube.net>2006-02-20 23:29:14 +0000
commit13c1afbcbbc71c64f41eb7d764917bb4fea9893f (patch)
treecea2711d376826e1ab7bb8829ab47e4a81fef7ba /program/include
parente687ff825dcd93cd8c007420d225917033605252 (diff)
Fixed some charset bugs
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc19
-rw-r--r--program/include/rcube_imap.inc2
-rw-r--r--program/include/rcube_shared.inc8
3 files changed, 19 insertions, 10 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 06d4d7b80..628866f35 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -308,11 +308,12 @@ function load_gui()
$OUTPUT->include_script('program/js/common.js');
$OUTPUT->include_script('program/js/app.js');
+ // set locale setting
+ rcmail_set_locale($sess_user_lang);
+
// set user-selected charset
if (!empty($CONFIG['charset']))
$OUTPUT->set_charset($CONFIG['charset']);
- else
- rcmail_set_locale($sess_user_lang);
// add some basic label to client
rcube_add_label('loading');
@@ -351,7 +352,7 @@ function rcmail_set_locale($lang)
if ($MBSTRING && function_exists("mb_language"))
{
- if (!mb_language(strtok($lang, "_")))
+ if (!@mb_language(strtok($lang, "_")))
$MBSTRING = FALSE; // unsupport language
}
@@ -662,6 +663,7 @@ function decrypt_passwd($cypher)
// send correct response on a remote request
function rcube_remote_response($js_code, $flush=FALSE)
{
+ global $OUTPUT, $CHARSET;
static $s_header_sent = FALSE;
if (!$s_header_sent)
@@ -673,7 +675,7 @@ function rcube_remote_response($js_code, $flush=FALSE)
}
// send response code
- print rcube_charset_convert($js_code, 'UTF-8', $GLOBALS['CHARSET']);
+ print rcube_charset_convert($js_code, $CHARSET, $OUTPUT->get_charset());
if ($flush) // flush the output buffer
flush();
@@ -888,7 +890,12 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
// encode for javascript use
if ($enctype=='js')
+ {
+ if ($OUTPUT->get_charset()!='UTF-8')
+ $str = rcube_charset_convert($str, $GLOBALS['CHARSET'], $OUTPUT->get_charset());
+
return preg_replace(array("/\r\n/", '/"/', "/([^\\\])'/"), array('\n', '\"', "$1\'"), strtr($str, $js_rep_table));
+ }
// encode for RTF
if ($enctype=='rtf')
@@ -1543,6 +1550,8 @@ EOF;
function rcmail_charset_selector($attrib)
{
+ global $OUTPUT;
+
// pass the following attributes to the form class
$field_attrib = array('name' => '_charset');
foreach ($attrib as $attr => $value)
@@ -1571,7 +1580,7 @@ function rcmail_charset_selector($attrib)
$select = new select($field_attrib);
$select->add(array_values($charsets), array_keys($charsets));
- $set = $_POST['_charset'] ? $_POST['_charset'] : $GLOBALS['CHARSET'];
+ $set = $_POST['_charset'] ? $_POST['_charset'] : $OUTPUT->get_charset();
return $select->show($set);
}
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 9777d4c18..71a5cb6ac 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -444,7 +444,7 @@ class rcube_imap
$count = iil_C_CountMessages($this->conn, $mailbox);
}
- if (is_array($a_mailbox_cache[$mailbox]))
+ if (!is_array($a_mailbox_cache[$mailbox]))
$a_mailbox_cache[$mailbox] = array();
$a_mailbox_cache[$mailbox][$mode] = (int)$count;
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 79428fa16..da5665199 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -86,13 +86,13 @@ class rcube_html_page
function set_charset($charset)
{
global $MBSTRING;
+
$this->charset = $charset;
- if ($MBSTRING&&function_exists( "mb_internal_encoding"))
+
+ if ($MBSTRING && function_exists("mb_internal_encoding"))
{
- if(!@mb_internal_encoding( $charset))
- {
+ if(!@mb_internal_encoding($charset))
$MBSTRING = FALSE;
- }
}
}