outputting iso-8859-1 chars

Morten Poulsen morten@afdelingp.dk
Thu Apr 25 02:00:00 GMT 2002


On Thu, 2002-04-25 at 01:02, Tom Tromey wrote:
> You don't say what platform you're on.  I assume you're on Linux.

Yes, Linux 2.4.14 on a PIII and a 7400.

> 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 `?'.

When I set my locale to da it still outouts a '?'.

> 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).

If I don't use it, I get
Hello.java:4: unrecognized character in input stream.
even for ISO-8859-1 characters in comments.

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

Thanks, that fixed it. I had the same problem when writing danish
characters to a socket. Inserting the above code fixed it there too.

Thanks for the help,
Morten

-- 
Morten Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/



More information about the Java mailing list