[xoops-cvslog 1215] CVS update: xoops2jp/html/language/japanese

アーカイブの一覧に戻る

NobuNobu nobun****@users*****
2005年 11月 25日 (金) 22:19:00 JST


Index: xoops2jp/html/language/japanese/xoopsmailerlocal.php
diff -u xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.1 xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.2
--- xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.1	Wed Oct 19 02:21:31 2005
+++ xoops2jp/html/language/japanese/xoopsmailerlocal.php	Fri Nov 25 22:19:00 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: xoopsmailerlocal.php,v 1.1.8.1 2005/10/18 17:21:31 minahito Exp $
+// $Id: xoopsmailerlocal.php,v 1.1.8.2 2005/11/25 13:19:00 nobunobu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -35,6 +35,7 @@
         $this->reset();
         $this->charSet = 'iso-2022-jp';
         $this->encoding = '7bit';
+		$this->multimailer->CharSet = $this->charSet;
     }
 
     function encodeFromName($text){
@@ -62,7 +63,7 @@
     --------------------------------------*/
     function STRtoJIS($str, $from_charset){
         if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
-            $str_JIS  = mb_convert_encoding($str, "ISO-2022-JP", $from_charset);
+            $str_JIS  = mb_convert_encoding($str, "ISO-2022-JP", $from_charset);
         } else if ($from_charset=='EUC-JP') {
             $str_JIS = '';
             $mode = 0;
@@ -105,7 +106,7 @@
 
     function XoopsMultiMailerLocal() {
         $this->XoopsMultiMailer();
-        
+
         $this->needs_encode = true;
         if (function_exists('mb_convert_encoding')) {
             $mb_overload = ini_get('mbstring.func_overload');
@@ -115,27 +116,57 @@
         }
     }
 
-    function addr_format($addr) {
+    function AddrFormat($addr) {
         if(empty($addr[1])) {
             $formatted = $addr[0];
         } else {
-            $formatted = sprintf('%s <%s>', $this->encode_header($addr[1], 'text', true), $addr[0]);
+            $formatted = $this->EncodeHeader($addr[1], 'text') . " <" . 
+                         $addr[0] . ">";
         }
         return $formatted;
     }
 
-    function encode_header ($str, $position = 'text', $force=false) {
-        if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
+    function EncodeHeader ($str, $position = 'text', $force=false) {
+        $encode_charset = strtoupper($this->CharSet);
+        if (function_exists('mb_convert_encoding')) { //Using mb_string extension if exists.
             if ($this->needs_encode || $force) {
-                $encoded = mb_convert_encoding($str, _CHARSET, mb_detect_encoding($str));
-                $encoded = mb_encode_mimeheader($encoded, "ISO-2022-JP", "B", "\n");
+            	$str_encoding = mb_detect_encoding($str, 'ASCII,'.$encode_charset );
+                if ($str_encoding == 'ASCII') { // Return original if string from only ASCII chars.
+                    return $str;
+                } else if ($str_encoding != $encode_charset) { // Maybe this case may not occur.
+                    $str = mb_convert_encoding($str, $encode_charset, $str_encoding);
+                }
+                //Following Logic are made for recovering PHP4.4.x mb_encode_mimeheader() bug.
+                //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic.
+                $cut_start = 0;
+                $encoded ='';
+                $cut_length = floor((76-strlen('Subject: =?'.$encode_charset.'?B?'.'?='))/4)*3;
+                while($cut_start < strlen($str)) {
+                    $partstr = mb_strcut ( $str, $cut_start, $cut_length, $encode_charset);
+                    $partstr_length = strlen($partstr);
+                    if (!$partstr_length) break;
+                    if ($encode_charset == 'ISO-2022-JP') { 
+                        //Should Adjust next cutting place for SO & SI char insertion.
+                        if ((substr($partstr, 0, 3)===chr(27).'$B') 
+                          && (substr($str, $cut_start, 3) !== chr(27).'$B')) {
+                            $partstr_length -= 3;
+                        }
+                        if ((substr($partstr,-3)===chr(27).'(B') 
+                          && (substr($str, $cut_start+$partstr_length-3, 3) !== chr(27).'(B')) {
+                            $partstr_length -= 3;
+                        }
+                    }
+                    if ($cut_start) $encoded .= "\r\n\t";
+                    $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?=';
+                    $cut_start += $partstr_length;
+                }
             } else {
                 $encoded = $str;
             }
         } else {
             $encoded = parent::encode_header($str, $position);
-        }
-        return $encoded;
+        }
+        return $encoded;
     }
 }
-?>
\ No newline at end of file
+?>


xoops-cvslog メーリングリストの案内
アーカイブの一覧に戻る