Preference that lets the whiners set cursor focus as needed when replying. :)
[squirrelmail.git] / functions / imap_utf7_local.php
index 261de0aa93abe7451d1ecff618cbaf993209a1fc..3435f48f06c566b39558e1249d73f8465984bc09 100644 (file)
@@ -8,7 +8,7 @@
  *
  * This implements all functions that do imap UTF7 conversions.
  *
- * $Id $
+ * $Id$
  */
 
 function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default_charset)
@@ -16,12 +16,11 @@ function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default
   // Allows mbstring functions only with iso-8859-*, utf-8 and 
   // iso-2022-jp (Japanese)
   // koi8-r and gb2312 can be added only in php 4.3+
-  if ( stristr('iso-8859-',$default_charset) ||
-       stristr('utf-8',$default_charset) || 
-       stristr('iso-2022-jp',$default_charset) ) {
+  if ( stristr($default_charset, 'iso-8859-') ||
+       stristr($default_charset, 'utf-8') || 
+       stristr($default_charset, 'iso-2022-jp') ) {
     if (function_exists('mb_convert_encoding')) {
-      set_my_charset();
-      return mb_convert_encoding($s, $to_encoding, $from_encoding);
+      return mb_convert_encoding($str, $to_encoding, $from_encoding);
     }
   }
   return '';
@@ -39,7 +38,8 @@ function imap_utf7_encode_local($s) {
       return '';
 
     global $default_charset;
-    if ($default_charset != 'iso-8859-1') {
+    set_my_charset();  //must be called before using $default_charset
+    if ((strtolower($default_charset) != 'iso-8859-1') && ($default_charset != '')) {
       $utf7_s = sqimap_mb_convert_encoding($s, 'UTF7-IMAP', $default_charset, $default_charset);
       if ($utf7_s != '')
         return $utf7_s;
@@ -91,7 +91,8 @@ function imap_utf7_decode_local($s) {
       return '';
 
     global $default_charset;
-    if ($default_charset != 'iso-8859-1') {
+    set_my_charset();  //must be called before using $default_charset
+    if ((strtolower($default_charset) != 'iso-8859-1') && ($default_charset != '')) {
       $utf7_s = sqimap_mb_convert_encoding($s, $default_charset, 'UTF7-IMAP', $default_charset);
       if ($utf7_s != '')
         return $utf7_s;