GCJ and Sun going GPL (again)

Chris Burdess dog@bluezoo.org
Wed Dec 6 10:17:00 GMT 2006


fernando@lozano.eti.br wrote:
> Well, Me and all Java developers I have worked with type non-ASCII characters in Java source files,
> and also in C, PHP, Perl, Python and other source files. I can't see why this should not be safe,
> and if I remember correctly it's explicitly supported by the Java language specification.

It is not safe because it requires others to guess what encoding you
were using to author your file. If they guess wrong, then they may
compile the wrong strings, strings that you didn't intend, into their
program.

Suppose you have written

  String zagolovok = "Литвиненко умер мусульманином";

in iso-8859-5 (quite natural, for Russian). Then someone comes along and
tries to compile your source file, but their locale is set to use
iso-8859-1 as an encoding. Remember, they're just compiling your
program. They probably never even looked at the contents of the source
file. So what they compile is

  String zagolovok = "»ØâÒØÝÕÝÚÞ ãÜÕà ÜãáãÛìÜÐÝØÝÞÜ";

This is a fundamental problem with the specification of Java language
source files, and inexperienced Java developers often get bitten by it.
-- 
Chris Burdess



More information about the Java mailing list