[rt-users] [fwd] rt-1.0.3 Japanese Patch (from: t2 at method.kusatsu.shiga.jp)

Jesse jesse at fsck.com
Tue Sep 12 01:21:00 EDT 2000


The following patch has been added to the RT contrib repository as
http://www.fsck.com/pub/rt/contrib/japanese.README.


        Jesse

----- Forwarded message from "Tadashi G. Takaoka" <t2 at method.kusatsu.shiga.jp> -----

From: "Tadashi G. Takaoka" <t2 at method.kusatsu.shiga.jp>
To: jesse at fsck.com
Cc: "Tadashi G. Takaoka" <t2 at method.kusatsu.shiga.jp>
Date: Tue, 12 Sep 2000 14:10:46 +0900
Subject: rt-1.0.3 Japanese Patch
X-Mailer: ARENA Internet Mailer 1.6.6 PPC

Hello, I am a user of Request Tracker.

It is nice system! But we Japanese using a complicated character encoding
systems.

    - JIS code (ISO2022JP) for email body.
    - MIME Base 64 for email header fields.
    - EUC-JP for MySQL database and Perl scripts.
    - Shift-JIS for personal computer's Web browser (GET/POST FORM data).

I was hacking rt-1.0.3 to deal with those character codes, and make a patch.

    - Incoming email JIS code and MIME Base 64 will convert to EUC.
    - Outgoing email will covert from EUC to JIS code and MIME Base 64.
    - Incoming web FORM variable values will convert to EUC.

It is a adhoc patch and dirty code, and requires following CPAN modules.

    - JCode 0.60
        http://search.cpan.org/search?module=Jcode
    - MIME::Base64 2.11
        http://search.cpan.org/search?module=MIME::Base64

If you are planning for support i18n character coding, please consider
my patch.

Thank you and good hacking.
--
TAKAOKA is gathering the P_O_W_E_R http://www.method.kusatsu.shiga.jp/~t2/



*** rt-1.0.3/lib/rt/support/mail.pm.orig    Fri Dec 10 20:38:51 1999
--- rt-1.0.3/lib/rt/support/mail.pm Mon Sep 11 19:26:50 2000
***************
*** 1,6 ****
--- 1,7 ----
  # $Header: /raid/cvsroot/rt/lib/rt/support/mail.pm,v 1.24 1999/12/10 11:38:51 tobiasb Exp $
  #
  
+ use Jcode;
  package rt;
  
  #####
***************
*** 35,40 ****
--- 36,58 ----
      return ($template);
  }
  
+ sub mime_encode {
+     local ($str) = @_;
+     my ($nstr, $j);
+     $j = Jcode::jcode("");
+     $nstr = "";
+     while ($str) {
+         if ($str =~ /^[\x00-\x7f]+/) {
+             $nstr .= $&;
+             $str = $';
+         } elsif ($str =~ /^[\x80-\xff]+( +[\x80-\xff]+)*/) {
+             $j->set($&);
+             $nstr .= $j->mime_encode;
+             $str = $';
+         }
+     }
+     return $nstr;
+ }
  
  # The return value should specify whether an error has occurred or
  # not, so errors might be returned to the UI. It seems to me the
***************
*** 100,120 ****
      #remove leading space
      $in_subject =~ s/^(\s*)//;
  
      open (MAIL, "|$rt::mailprog $rt::mail_options");
      
!     print  MAIL "Subject: [$rt::rtname \#". $in_serial_num . "] ($in_queue_id) $in_subject
! Reply-To: $friendly_name <$temp_mail_alias>
! From: $friendly_name <$temp_mail_alias>
! To: $in_recipient   
! Cc: $in_cc
! Bcc: $in_bcc
  X-Request-ID: $in_serial_num
  X-RT-Loop-Prevention: $rt::rtname
  X-Sender: $in_current_user
  X-Managed-By: Request Tracker $rt::rtversion (http://www.fsck.com/projects/rt)
  Precedence: $precedence 
  
! $template
  -------------------------------------------- Managed by Request Tracker\n";
      if (close (MAIL)) {
        return("template_mail:Message Sent");
--- 118,148 ----
      #remove leading space
      $in_subject =~ s/^(\s*)//;
  
+     $mime_subject = &mime_encode($in_subject);
+     $mime_friendly_name = &mime_encode($friendly_name);
+     $mime_recipient = &mime_encode($in_recipient);
+     $mime_cc = &mime_encode($in_cc);
+     $mime_bcc = &mime_encode($in_bcc);
+     $jis_template = Jcode::jcode($template)->jis;
+ 
      open (MAIL, "|$rt::mailprog $rt::mail_options");
      
!     print  MAIL "Subject: [$rt::rtname \#". $in_serial_num . "] ($in_queue_id) $mime_subject
! Reply-To: $mime_friendly_name <$temp_mail_alias>
! From: $mime_friendly_name <$temp_mail_alias>
! To: $mime_recipient   
! Cc: $mime_cc
! Bcc: $mime_bcc
  X-Request-ID: $in_serial_num
  X-RT-Loop-Prevention: $rt::rtname
  X-Sender: $in_current_user
  X-Managed-By: Request Tracker $rt::rtversion (http://www.fsck.com/projects/rt)
  Precedence: $precedence 
+ MIME-Version: 1.0
+ Content-Type: text/plain; charset=\"iso-2022-jp\"
+ Content-Transfer-Encoding: 7bit
  
! $jis_template
  -------------------------------------------- Managed by Request Tracker\n";
      if (close (MAIL)) {
        return("template_mail:Message Sent");
*** rt-1.0.3/lib/rt/ui/mail/manipulate.pm.orig  Wed Mar 22 19:23:09 2000
--- rt-1.0.3/lib/rt/ui/mail/manipulate.pm   Fri Sep  8 16:49:47 2000
***************
*** 1,3 ****
--- 1,5 ----
+ use Jcode;
+ 
  package rt::ui::mail::manipulate;
  
  sub activate {
***************
*** 97,103 ****
  sub read_mail_from_stdin {
    local $content;
    while (<STDIN>){
!     $content .= $_;
    }
    return ($content);
  }
--- 99,105 ----
  sub read_mail_from_stdin {
    local $content;
    while (<STDIN>){
!     $content .= Jcode::jcode($_)->mime_decode;
    }
    return ($content);
  }
*** rt-1.0.3/lib/rt/ui/web/support.pm.orig  Wed Jul  7 11:58:49 1999
--- rt-1.0.3/lib/rt/ui/web/support.pm   Mon Sep 11 19:34:35 2000
***************
*** 3,8 ****
--- 3,9 ----
  # RT is (c) Copyright 1996-1999 Jesse Vincent
  # RT is distributed under the terms of the GNU General Public License
  
+ use Jcode;
  
  package rt::ui::web;
  
***************
*** 148,153 ****
--- 149,158 ----
      use CGI qw/:cgi-lib/;
      $query = new CGI;
      %FORM = $query->Vars;
+ 
+     foreach my $v (keys %FORM) {
+         $FORM{$v} = Jcode::jcode($FORM{$v})->euc;
+     }
  
      # Pull in the cookies
      use CGI::Cookie;


----- End forwarded message -----

-- 
jesse reed vincent --- root at eruditorum.org --- jesse at fsck.com 
pgp keyprint: 50 41 9C 03 D0 BC BC C8 2C B9 77 26 6F E1 EB 91
-------------------------------------------------------------
pretty soon we're going to HAVE to have hypertext mail!
				--Tim Berners Lee. (8 Jan 1993 on www-talk)





More information about the rt-users mailing list