last try to fix greek chars
[squirrelmail.git] / functions / i18n.php
index 92deb52aaab24715da76c35e01b0c18a9e4935f3..481d27b02a930b74ba2a31b7bbb035da06b4e356 100644 (file)
@@ -492,7 +492,7 @@ function charset_decode_iso_8859_7 ($string) {
      * ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6)
      * These are Unicode 900-902
      */
-    $string = preg_replace("/([\264-\266])/","'&#' . (ord(\\1)+720)",$string);
+    $string = preg_replace("/([\264-\266])/e",'&#' . (ord("\\1")+720),$string);
     
     /* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */
     $string = str_replace("\267", '·', $string);
@@ -501,7 +501,7 @@ function charset_decode_iso_8859_7 ($string) {
      * ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA)
      * These are Unicode 900-902
      */
-    $string = preg_replace("/([\270-\272])/","'&#' . (ord(\\1)+720)",$string);
+    $string = preg_replace("/([\270-\272])/e",'&#' . (ord("\\1")+720),$string);
 
     /*
      * 11/11 (0xBB) Right angle quotation mark is the same as in
@@ -510,7 +510,7 @@ function charset_decode_iso_8859_7 ($string) {
     $string = str_replace("\273", '»', $string);
 
     /* And now the rest of the charset */
-    $string = preg_replace("/([\274-\376])/","'&#' . (ord(\\1)+720)",$string);
+    $string = preg_replace("/([\274-\376])/",'&#'.(ord("\\1")+720),$string);
 
     return $string;
 }
@@ -785,7 +785,7 @@ function charset_decode_koi8r ($string) {
 function set_up_language($sm_language, $do_search = false) {
 
     static $SetupAlready = 0;
-    global $HTTP_ACCEPT_LANGUAGE, $use_gettext, $languages,
+    global $use_gettext, $languages,
            $squirrelmail_language, $squirrelmail_default_language,
            $sm_notAlias;
 
@@ -794,8 +794,8 @@ function set_up_language($sm_language, $do_search = false) {
     }
     $SetupAlready = TRUE;
 
-    if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) {
-        $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
+    if ($do_search && ! $sm_language && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+        $sm_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
     }
     
     if (!$sm_language && isset($squirrelmail_default_language)) {
@@ -1038,7 +1038,7 @@ if ($gettext_flags == 7) {
 /* If we can fake gettext, try that */
 elseif ($gettext_flags == 0) {
     $use_gettext = true;
-    include_once('../functions/gettext.php');
+    include_once(SM_PATH . 'functions/gettext.php');
 } else {
     /* Uh-ho.  A weird install */
     if (! $gettext_flags & 1) {
@@ -1090,7 +1090,33 @@ function japanese_charset_xtra() {
             $ret = mb_strimwidth($ret, 0, $width, '...'); 
             break;
         case 'encodeheader':
-            $ret = mb_encode_mimeheader($ret);
+            $result = '';
+            if (strlen($ret) > 0) {
+                $tmpstr = mb_substr($ret, 0, 1);
+                $prevcsize = strlen($tmpstr);
+                for ($i = 1; $i < mb_strlen($ret); $i++) {
+                    $tmp = mb_substr($ret, $i, 1);
+                    if (strlen($tmp) == $prevcsize) {
+                        $tmpstr .= $tmp;
+                    } else {
+                        if ($prevcsize == 1) {
+                            $result .= $tmpstr;
+                        } else {
+                            $result .= mb_encode_mimeheader($tmpstr);
+                        }
+                        $tmpstr = $tmp;
+                        $prevcsize = strlen($tmp);
+                    }
+                }
+                if (strlen($tmpstr)) {
+                    if (strlen(mb_substr($tmpstr, 0, 1)) == 1)
+                        $result .= $tmpstr;
+                    else
+                        $result .= mb_encode_mimeheader($tmpstr);
+                }
+            }
+            $ret = $result;
+            //$ret = mb_encode_mimeheader($ret);
             break;
         case 'decodeheader':
             $ret = str_replace("\t", "", $ret);
@@ -1140,4 +1166,4 @@ function korean_charset_xtra() {
     return $ret;
 }
 
-?>
\ No newline at end of file
+?>