Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

wrong character encoding in error messages

997198Mar 15 2013 — edited Mar 15 2013
The Java compiler can be adjusted to source file encoding with the option javac -encoding ...
The Java runtime can be adjusted to terminal encoding with java -Dfile.encoding=...
While this appears somehow inconsistent, it works and can be used e.g. when running the tools from Cygwin (the POSIX layer on Windows) which uses UTF-8 by default, while Java, following the Windows mechanism, uses some other character encoding by default (this works more seemlessly on Unix/Linux, by the way).

Now if I compile UTF-8 source with non-ASCII characters, and there is an error message related to them, the error message printed to the console will not be UTF-8 encoded, resulting in mangled text output.

(Arguably, source and terminal encoding could be different, but then there is no option available to the compiler to adjust this;
it does not accept -Dfile.encoding=....)

Example: Error message looks like this:
FM.java:1: error: class, interface, or enum expected
b▒h
While the string is actually "bäh" in the source.

This is a bug. Any proper place to actually report a bug?

Edited by: 994195 on 15-Mar-2013 09:42
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2013
Added on Mar 15 2013
1 comment
2,026 views