This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: outputting iso-8859-1 chars
- From: Tom Tromey <tromey at redhat dot com>
- To: Morten Poulsen <morten at afdelingp dot dk>
- Cc: java at gcc dot gnu dot org
- Date: 24 Apr 2002 17:02:19 -0600
- Subject: Re: outputting iso-8859-1 chars
- References: <1019683994.8904.26.camel@marvin>
- Reply-to: tromey at redhat dot com
>>>>> "Morten" == Morten Poulsen <morten@afdelingp.dk> writes:
Morten> I want to output a char (eg. the Danish å, 229 in
Morten> ISO-8859-1). It works just fine when the class is compiled
Morten> with javac or gcj
You don't say what platform you're on. I assume you're on Linux.
On Linux the Sun JVM assumes that the C locale uses ISO-8859-1, when
in fact it uses ASCII. libgcj respects this difference and outputs
just ASCII, meaning that character > 0x7f is printed as `?'.
This is sort of a pedantic difference, I guess, but I think it is the
cause of your problem.
Morten> mortenp@marvin:/tmp$ gcj --encoding=iso-8859-1 --main=Hello Hello.java
FYI, `gcj --encoding' tells gcj the encoding of your .java file. it
doesn't affect the runtime behavior of your program (well, it can,
since a given sequence of bytes in the input file can have a different
meaning).
Morten> I have compiled the class and looked at the string in the
Morten> assembler code. It looks unicode-ish?
Yes. Internally all string constants are represented as UTF-8. That
is how they are written to the assembler as well. At runtime they are
turned into UCS-2 (Java String encoding).
Morten> Isn't it possible to use ISO-8859-1 characters in strings,
Morten> when using gcj, or am I doing something wrong?
Your problem is almost certainly on the printing end of things. Try
setting your locale to something that uses ISO-8859-1. Or try using
`new OutputStreamWriter (System.out, "ISO-8859-1")'
Tom