This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: outputting iso-8859-1 chars


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]