This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCJ and Sun going GPL (again)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]