Actually, I have noticed one problem that so far is a mystery to me.
Somehow under Linux (with JDK 1.2.2) something seems to get lost when
trying to write to an OutputStreamWriter with a specified encoding, if
the string is not iso-8859-1, but my machine is. Sun has some sample
code on their I18N (actually, the very last example) that I cannot get
to work on Linux. No idea why, and I spent many many hours trying to
figure it out.
The code is supposed to write some Japanese String (in \unnn notation)
to an OutputStreamWriter, like:
OutputStreamWriter out = new OutputStreamWriter (new
FileOutPutStream("test.txt"), "UTF8");
out.write("\u672c\u8a9e");
Then the code is supposed to read from that test.txt file by doing the
reverse, with an InputStreamWriter that specifies the encoding. There's
no way I could get this to work; my pretty Japanese string gets
completely garbled, no matter what encoding I specify, including if I
don't specify one at all (in which case it would use 8859_1.
So far, I've only succeeded in writing a shift-jis file, for example, by
doing something like
byte[] testArray = testString.getBytes("SJIS") and then writing that
array directly to a FileOutputStream (again starting with a testString
in \unnnn notation).
So maybe someone here knows what could be going on under the covers??
Renzo
[EMAIL PROTECTED] wrote:
>
> Renzo:
>
> Thank you very much for your help and information. It's very helpful.
>
> I'll send time to digest all of the information and give it a try.
>
> Regards,
>
> PS. This msg may not be able to be posted in the mail list. I don't know
> why.
>
> Lee
>
> -----Original Message-----
> From: Renzo Pecoraro [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 14, 2000 2:15 PM
> To: [EMAIL PROTECTED]
> Subject: Java-Linux I18N
>
> Couple of hints on this.
>
> So far, I haven't seen anything in Java I18N that's specific to Linux,
> except:
>
> 1. Yes, you need Asian fonts. Some come with the distros, I got
> additional ones from
> http://www.userfriendly.net/linux/RPM/rhcn/noarch/X11_fonts.html
> (Japanese, Simplified Chinese, Traditional Chinese, Korean) - these are
> all RPMs
>
> 2. You do need to change you font.properties file in order to display
> Asian in a Java program. But once you have that, you can display it,
> even if your machine uses the Western European codepage (i.e.is set up
> to behave as a Western European/US machine) - EXCEPT, as of pre-Swing,
> TextField and TextArea will NOT display Asian, because these components
> use native code (or for whatever reason). From what I understand Swing
> components do not have that limitation. Now, there's a great site for
> Japanese Linux at
> http://hikari.tlug.gr.jp/~craigoda/writings/linux-nihongo/linux-nihongo.html
> ,
> including references to Java, and most importantly a font.properties
> file for Linux. I simply downloaded that file, dropped it into my
> ../jre/lib directory of Java installation and into
> /usr/lib/netscape/java/classes for my netscape browser. BUT, if you
> backup your existing font.properties file (as you would want to) to
> java.properties.en (as it would logically be named), your JVM (of the
> JRE or Netscape's) seems to still look up the fonts described in that
> backed up file, if your machine's default Locale is English. So I backed
> mine up to font.properties.ENGLISH (which the JVM apparently cannot map
> to my machines Locale), and then it works beautifully - EXCEPT that some
> Western European fonts are now not quite so pretty. Of course, you can
> and probably should edit that font.properties file, but the one
> downloaded from
> http://hikari.tlug.gr.jp/~craigoda/writings/linux-nihongo/linux-nihongo.html
> is a great starting point.
>
> 3. I am fairly certain that there is a way to switch the locale and
> charset/codepage of your machine (hence the /etc/charset directory, I'd
> think), but I haven't figured it out yet (although I will have to for a
> project sometime soon).
>
> 4. From what I can tell, the rest is Java I18N as usual. See the I18N
> Tutorial at http://java.sun.com/docs/books/tutorial/i18n/TOC.html. There
> was also a three-part tutorial at http://www.javaworld.com at somepoint.
> Take the first first example of that tutorial and add Japanese to the
> choices ("ja", "JP") to allow you to test whether you have correctly
> installed the font.properties file. If you did, you'll see Japanese
> characters when you select Japanese in this applet (in appletviewer or
> in the browser).
>
> Hope this helps.
> Renzo
>
> > > [Lee]
> > > I'm new in this area too (and new in Java-Linux as well). The issue of
> > I18N
> > > I have is very basic at this time. That is what we need and need to do
> to
> > > display Japanese and Chinese characters on a JButton on Linux.
> > >
> > > Q1: Do we need a Japanese/Chinese font packages?
> > > Q2: If so, where to find the right font package for Linux?
> > > Q3: After find the font package, how to use it to show a
> Japanese/Chinese
> > > character on a JButton?
> > > Q4: Is there any Japanese/Chinese version of Linux like Windows NT does?
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]