Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: Java and Japanese e-mail



--------------------------------------------------------
tlug note from "Stephen J. Turnbull" <turnbull@example.com>
--------------------------------------------------------
>>>>> "Craig" == Craig Oda <craig@example.com> writes:

    Craig> I'm using a Java servlet on Linux and Java object on Linux
    Craig> to send the contents of a form to some people.  The
    Craig> contents of the form are in Japanese.  It could either be
    Craig> EUC or ShiftJIS.  I've never done this before, and assume
    Craig> that there is a simple answer.

Why?  Java is officially Unicode, but I haven't seen any real support
in the JDK or docs (but I haven't looked in about 3 months ;-)

My feeling back then was that basically there was a lot of work to be
done on Java i18n, in particular making translator objects.

    Craig> My object works fine with ASCII, but I think I need to
    Craig> convert to JIS before talking to sendmail.

RFC-wise, you should (or do something else about 8-bit munging
relays), but in practice this should not faze the mail transport
system (sendmail).

    Craig> In order to send the mail I am connecting directly to the
    Craig> SMTP port on 25 and sending the greeting and data.  My
    Craig> assumption is that I need to convert the Japanese into JIS
    Craig> before sending.  Is this correct?  I'm doing it with
    Craig> ShiftJIS (not my machine :-) and getting bakemoji.

Are you sure the MTA (sendmail) is getting confused, and not the
receiving MUA?  Ie, do you have something as smart as Mule to look at
the alleged mojibake and see that it really is munged?

    Craig> I'm curious about a couple things, 1) is there an easier
    Craig> way to do this? 2) has anyone sent Japanese with Java
    Craig> before?

    Craig> Also, anyone interesting in starting a seperate Java
discussion thread?


My code fragment to follow.  It works with ASCII.

        try { 
          // open a network socket on the SMTP port
          Socket server = new Socket("mail.twics.com", 25);     

          // set up network print stream
          PrintWriter sendmailout =
            new PrintWriter(
                            new BufferedWriter(
                                             new OutputStreamWriter(server.getOutputStream())), true);

         // send mail greetings and message
          sendmailout.println("HELO my-machine.twics.com\n" 
                               + "MAIL FROM:<whoever@example.com>\n"
                               + "RCPT TO:<person@example.com>\n"
                               + "DATA\n");

          // send the body of the e-mail here
          sendmailout.println("Hi, this is an automated message"
                              + " with the results of the "
                              + "form." );
          
          Date date_written = new Date();
          sendmailout.println("This note was sent on " + date_written);

    // the mail program requires a single dot on a line
          // by itself
          sendmailout.println(".");
          sendmailout.println("QUIT");
          sendmailout.close();
            



--------------------------------------------------------
"Knowledge is the air and light of civilization.  Transform it and you
transform all else."
Craig Oda 	craig@example.com	
   TWICS - IEC Building, 1-21 Yotsuya, Shinjuku-ku, Tokyo 160 JAPAN
Main Reception: 03-3351-5977	Fax: +81-3-3353-6096

Next TLUG meeting is Saturday October 11, 1997
-----------------------------------------------------------------
a word from the sponsor will appear below
TWICS - Japan's First Public-Access Internet System.
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096
Next TLUG meeting is Saturday October 11, 1997
-----------------------------------------------------------------
a word from the sponsor will appear below
TWICS - Japan's First Public-Access Internet System.
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links