This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
outputting iso-8859-1 chars
- From: Morten Poulsen <morten at afdelingp dot dk>
- To: java at gcc dot gnu dot org
- Date: 24 Apr 2002 23:33:14 +0200
- Subject: outputting iso-8859-1 chars
Hi,
I want to output a char (eg. the Danish å, 229 in ISO-8859-1). It works
just fine when the class is compiled with javac or gcj
--encoding=ISO_8859-1 -C, and executed with a normal JVM. The class is
this:
class Hello {
public final static void main(String[] args) {
System.out.println("xxxåxxx");
}
}
However, if I compile it to a native binary, it outputs a question mark
where the å should have been.
mortenp@marvin:/tmp$ gcj --encoding=iso-8859-1 --main=Hello Hello.java
mortenp@marvin:/tmp$ ./a.out
xxx?xxx
The closest (I guess) hint I got when searching google was a patch at
http://gcc.gnu.org/ml/java-patches/2000-q4/msg00077.html which has the
line
+ buf[count++] = (byte) ((c > 0xff) ? '?' : c);
in "public class Output_8859_1 extends UnicodeToBytes". It outputs a
question mark if the character is out of range - but å shouldn't be out
of range.
I have compiled the class and looked at the string in the assembler
code. It looks unicode-ish?
mortenp@marvin:/tmp$ gcj --encoding=iso-8859-1 -S Hello.java
mortenp@marvin:/tmp$ fgrep xxx Hello.s
.ascii "xxx\303\245xxx"
I am using gcj 3.0.4 from Debian.
Isn't it possible to use ISO-8859-1 characters in strings, when using
gcj, or am I doing something wrong?
Thanks,
Morten