Masato
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 22 Aug 2002 09:18:54 +0000 (09:18 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 22 Aug 2002 09:18:54 +0000 (09:18 +0000)
Japanese encodings

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3402 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/i18n.php

index 82242dd3a543d5a2b7505d7fb9d378dc1a5ae540..cf7750d9ad6b08c820044d74a84f89c3405a05e1 100644 (file)
@@ -18,6 +18,8 @@
 /* Decodes a string to the internal encoding from the given charset */
 function charset_decode ($charset, $string) {
 
 /* Decodes a string to the internal encoding from the given charset */
 function charset_decode ($charset, $string) {
 
+    $string = charset_decode_japanese($string);
+
     /* All HTML special characters are 7 bit and can be replaced first */
     $string = htmlspecialchars ($string);
 
     /* All HTML special characters are 7 bit and can be replaced first */
     $string = htmlspecialchars ($string);
 
@@ -673,6 +675,32 @@ function charset_decode_koi8r ($string) {
     return $string;
 }
 
     return $string;
 }
 
+/*
+ * for japanese
+ */
+function charset_decode_japanese($string)
+{
+    global $squirrelmail_language;
+    if ($squirrelmail_language == 'ja_JP' && function_exists('mb_detect_encoding')) {
+        $detect_encoding = mb_detect_encoding($string);
+        if ($detect_encoding == 'JIS' || $detect_encoding == 'EUC-JP' || $detect_encoding == 'SJIS') {
+            $string = mb_convert_encoding($string, 'EUC-JP', 'AUTO');
+        }
+    }
+    return $string;
+}
+function charset_encode_japanese($string)
+{
+    global $squirrelmail_language;
+    if ($squirrelmail_language == 'ja_JP' && function_exists('mb_detect_encoding')) {
+        $detect_encoding = mb_detect_encoding($string);
+        if ($detect_encoding == 'JIS' || $detect_encoding == 'EUC-JP' || $detect_encoding == 'SJIS') {
+            $string = mb_convert_encoding($string, 'JIS', 'AUTO');
+        }
+    }
+    return $string;
+}
+
 /*
  * Set up the language to be output
  * if $do_search is true, then scan the browser information
 /*
  * Set up the language to be output
  * if $do_search is true, then scan the browser information
@@ -717,9 +745,18 @@ function set_up_language($sm_language, $do_search = false) {
         }
         setlocale(LC_ALL, $sm_notAlias);
         $squirrelmail_language = $sm_notAlias;
         }
         setlocale(LC_ALL, $sm_notAlias);
         $squirrelmail_language = $sm_notAlias;
+        if ($squirrelmail_language == 'ja_JP') {
+            header ('Content-Type: text/html; charset=EUC-JP');
+            if (!function_exists('mb_internal_encoding')) {
+                echo _("You need to have php4 installed with the multibyte string function enabled (using configure option --with-mbstring).");
+            }
+            mb_internal_encoding('EUC-JP');
+            mb_http_output('pass');
+        } else {
         header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
     }
 }
         header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
     }
 }
+}
 
 function set_my_charset(){
 
 
 function set_my_charset(){
 
@@ -820,6 +857,10 @@ $languages['it_IT']['NAME']    = 'Italian';
 $languages['it_IT']['CHARSET'] = 'iso-8859-1';
 $languages['it']['ALIAS'] = 'it_IT';
 
 $languages['it_IT']['CHARSET'] = 'iso-8859-1';
 $languages['it']['ALIAS'] = 'it_IT';
 
+$languages['ja_JP']['NAME']    = 'Japanese';
+$languages['ja_JP']['CHARSET'] = 'iso-2022-jp';
+$languages['ja']['ALIAS'] = 'ja_JP';
+
 $languages['ko_KR']['NAME']    = 'Korean';
 $languages['ko_KR']['CHARSET'] = 'euc-KR';
 $languages['ko']['ALIAS'] = 'ko_KR';
 $languages['ko_KR']['NAME']    = 'Korean';
 $languages['ko_KR']['CHARSET'] = 'euc-KR';
 $languages['ko']['ALIAS'] = 'ko_KR';