diff options
author | thomascube <thomas@roundcube.net> | 2005-10-21 12:12:23 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2005-10-21 12:12:23 +0000 |
commit | a95e0e174c48b7c5242b8969aef99838a52c41ee (patch) | |
tree | eb87cb9c33433269d2f2376e841e1d6d66eff667 /program/include | |
parent | 7902df457d3401c83f78a6ddd48df1a7f07f68b1 (diff) |
Improved support for UTF-8 and other charsets
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/main.inc | 2 | ||||
-rw-r--r-- | program/include/rcube_imap.inc | 23 | ||||
-rw-r--r-- | program/include/rcube_shared.inc | 27 |
3 files changed, 38 insertions, 14 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 4a872a580..fb9d35081 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -697,7 +697,7 @@ function rcube_xml_command($command, $str_attrib, $a_attrib=NULL) else if (isset($GLOBALS['PAGE_TITLE'])) return rep_specialchars_output("RoundCube|Mail :: ".$GLOBALS['PAGE_TITLE']); else if ($task=='mail' && ($mbox_name = $IMAP->get_mailbox_name())) - return "RoundCube|Mail :: $mbox_name"; + return "RoundCube|Mail :: ".rep_specialchars_output(UTF7DecodeString($mbox_name), 'html', 'all'); else return "RoundCube|Mail :: $task"; } diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index 83ee32158..009c80add 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -23,6 +23,7 @@ require_once('lib/imap.inc'); require_once('lib/mime.inc'); +require_once('lib/utf7.inc'); class rcube_imap @@ -723,6 +724,19 @@ class rcube_imap } + // clear all messages in a specific mailbox + function clear_mailbox($mbox) + { + $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox; + $msg_count = $this->_messagecount($mailbox, 'ALL'); + + if ($msg_count>0) + return iil_C_ClearFolder($this->conn, $mailbox); + else + return 0; + } + + // send IMAP expunge command and clear cache function expunge($mbox='', $clear_cache=TRUE) { @@ -801,18 +815,19 @@ class rcube_imap function create_mailbox($name, $subscribe=FALSE) { $result = FALSE; - $abs_name = $this->_mod_mailbox($name); + $name_enc = UTF7EncodeString($name); + $abs_name = $this->_mod_mailbox($name_enc); $a_mailbox_cache = $this->get_cache('mailboxes'); //if (strlen($this->root_ns)) // $abs_name = $this->root_ns.$abs_name; if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) - $result = iil_C_CreateFolder($this->conn, iil_utf7_encode($abs_name)); + $result = iil_C_CreateFolder($this->conn, $abs_name); // update mailboxlist cache if ($result && $subscribe) - $this->subscribe($name); + $this->subscribe($name_enc); return $result ? $name : FALSE; } @@ -1057,7 +1072,7 @@ class rcube_imap // convert body chars according to the ctype_parameters function charset_decode($body, $ctype_param) { - if (is_array($ctype_param) && strlen($ctype_param['charset'])) + if (is_array($ctype_param) && !empty($ctype_param['charset'])) return decode_specialchars($body, $ctype_param['charset']); return $body; diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index 8396f99d6..6874094a1 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -1032,7 +1032,7 @@ function rcube_browser() function rcube_label($attrib) { global $sess_user_lang, $INSTALL_PATH; - static $sa_text_data, $s_language; + static $sa_text_data, $s_language, $utf8_decode; // extract attributes if (is_string($attrib)) @@ -1071,6 +1071,12 @@ function rcube_label($attrib) $sa_text_data = array_merge($sa_text_data, $messages); } + if (isset($utf8_decoding) && $utf8_decoding==TRUE) + { + @include_once('lib/utf8.inc'); + $utf8_decode = TRUE; + } + $s_language = $sess_user_lang; } @@ -1109,10 +1115,6 @@ function rcube_label($attrib) if ($text=='') $text = $a_text_item['single']; - // perform utf-8 decoding - //if (function_exists('utf8_decode')) - // $text = utf8_decode($text); - // replace vars in text if (is_array($attrib['vars'])) { @@ -1130,6 +1132,11 @@ EOF; "); + // perform utf-8 decoding + if ($utf8_decode && function_exists('utf8ToUnicodeEntities')) + $text = utf8ToUnicodeEntities($text); + + // format output if (($attrib['uppercase'] && strtolower($attrib['uppercase']=='first')) || $attrib['ucfirst']) return ucfirst($text); @@ -1189,12 +1196,11 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE) if (!$html_encode_arr) { $html_encode_arr = get_html_translation_table(HTML_ENTITIES); - $html_encode_arr["?"] = '–'; $html_encode_arr[chr(128)] = '€'; unset($html_encode_arr['?']); unset($html_encode_arr['&']); } - + $ltpos = strpos($str, '<'); $encode_arr = $html_encode_arr; @@ -1254,8 +1260,11 @@ function decode_specialchars($input, $charset='') { $charset = strtolower($charset); - if (strcasecmp($charset, 'utf-8')==0) - return utf8_decode($input); + if ($charset=='utf-8') + { + require_once('lib/utf8.inc'); + return utf8ToUnicodeEntities($input); + } else if ($charset=="koi8-r") return convert_cyr_string($input, 'k', 'w'); else if ($charset=="iso8859-5") |