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 Craig Oda <craig@example.com>
--------------------------------------------------------
Hi,
first I would like to thank Stephen Turnbull for answering
my questions and make me contemplate the difference between
a byte and a character.  In Java, the char is 16 bit
unicode and byte is a signed 8 bit integer.  What I wrongly
assumed was that a String, array of char, could be used
like an array of bytes.  

>From Todd Rudick, I got this bit of information:

Java uses Unicode internally, and has full support for many encodings
externally. 
  For example, to convert an array of bytes that contains SJIS portions to
a Unicode string, you can type: 
  uniString = new String(sjisByteArray, "SJIS");
  
To convert that from Unicode to a JIS byte array:
  byte[] jisByteArray = uniString.getBytes("JIS");

--

This was extremely enlightening and I would like to send my
thanks on this bit of info.  If I can get an array of bytes,
then I can get to Unicode and output any encoding I want.
This is quite a cool way to handle multi-languages in
Java 1.1.

---

My problem right now is that I can't figure out how to
get the servlet to receive a byte stream from the HTTP server.

I have these methods:


getAttribute(String) 
     Returns the value of the named attribute of the request, or null if
     the attribute does not exist. 

getContentLength() 
     Returns the size of the request entity data, or -1 if not known. 

getContentType() 
     Returns the Internet Media Type of the request entity data, or null
     if not known. 
getInputStream() 
     Returns an input stream for reading the request body. 

getParameter(String) 
     Returns a string containing the lone value of the specified
     parameter, or null if the parameter does not exist. 

getParameterNames() 
     Returns the parameter names for this request as an enumeration of
     strings, or an empty enumeration if there are no
     parameters or the input stream is empty. 

getParameterValues(String) 
     Returns the values of the specified parameter for the request as an
     array of strings, or null if the named parameter does not
     exist. 


-----

I've been using  getParameter("name");
For example, if an HTML form is 

<FORM METHOD=GET
ACTION="http://cow.farm.twics.com/village-bin/servlet.sh/test">
0L>A0B: <INPUT TYPE="TEXT" NAME="name" SIZE=20><BR>
<INPUT TYPE="submit" NAME="request" VALUE="Send">
</FORM>

I get the parameter with

  String name_ = getParameter("name");

Then, I can just mail the name_ string or save it to
a file. 

However, if the person viewing the HTML is using a Macintosh
Kanji talk or Japanese Windows computer, they input ShiftJIS to
the form and it sends ShiftJIS.

Thus, the String is not usuable.  Right?   I have to think
about this some more.

I've almost solved the kaffe problem.  I'm going to take a
rest on this Japanese problem and look at kaffe again after
dinner.

Regards,
Craig


--------------------------------------------------------
"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


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links