Added optional mbstring functions to deal with i18n folder names
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 20 Jul 2003 16:17:08 +0000 (16:17 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 20 Jul 2003 16:17:08 +0000 (16:17 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5355 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_utf7_local.php

index c2c9ae538d97f1239848477a1e4c28cea8775b26..7845792795bc17a4833c6611ac3ea7c12b190940 100644 (file)
@@ -18,6 +18,24 @@ function imap_utf7_encode_local($s) {
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
         return $languages[$squirrelmail_language]['XTRA_CODE']('utf7-imap_encode', $s);
     }
+
+    global $default_charset;
+    set_my_charset();
+
+    if ( ! $default_charset == "iso-8859-1" ) {
+      // 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 ( preg_match("/iso-8859-/i",$default_charset) ||
+          preg_match("/utf-8/i",$default_charset) || 
+          preg_match("/iso-2022-jp/i",$default_charset) ) {
+       if(function_exists("mb_convert_encoding")) {
+         return mb_convert_encoding($s, "UTF7-IMAP", $default_charset);
+       }
+      }
+    }
+
+    // Later code works only for ISO-8859-1 
     
        $b64_s = '';    // buffer for substring to be base64-encoded
        $utf7_s = '';   // imap-utf7-encoded string
@@ -58,6 +76,24 @@ function imap_utf7_decode_local($s) {
         function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
         return $languages[$squirrelmail_language]['XTRA_CODE']('utf7-imap_decode', $s);
     }
+
+    global $default_charset;
+    set_my_charset();
+
+    if ( ! $default_charset == "iso-8859-1" ) {
+      // 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 ( preg_match("/iso-8859-/i",$default_charset) ||
+          preg_match("/utf-8/i",$default_charset) || 
+          preg_match("/iso-2022-jp/i",$default_charset) ) {
+       if(function_exists("mb_convert_encoding")) {
+         return mb_convert_encoding($s, $default_charset, "UTF7-IMAP");
+       }
+      }
+    }
+
+    // Later code works only for ISO-8859-1
     
        $b64_s = '';
        $iso_8859_1_s = '';