outputting iso-8859-1 chars
Morten Poulsen
morten@afdelingp.dk
Wed Apr 24 15:56:00 GMT 2002
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 "xxx303円245円xxx"
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
More information about the Java
mailing list