Consider the following EncodingTest.java file:

public class EncodingTest {
    public static void main(String[] args) {
         String s = "José";
         System.out.println(s);
    }
}

If you compile it like this:

$ javac EncodingTest.java

it will show the characters wrong when I open it in JD-GUI. And the following:

$ javac -encoding UTF8 EncodingTest.java

will display the characters correctly in JD-GUI.

Ironically when you run it, the one that displays correctly in Terminal is the one that does not display correctly in JD-GUI. And I have terminal configured to use UTF-8 by going into Terminal : Preferences : Settings : Advanced. So this is a crazy world.




On Mar 19, 2009, at 7:53 PM, Ricardo J. Parada wrote:

Ok... I'm really close to solving this:

If I modify the build.xml file as follows:

207c207
<            <wocompile srcdir="Sources" destdir="bin">
---
>            <wocompile srcdir="Sources" destdir="bin" encoding="UTF8">

then my .java files are compiled as UTF8 files and now I see the characters correctly in JD-GUI. And the application built from the command line displays the characters correctly when I run it.

Hmmm.... this STILL DOES NOT explain why my other small wonder app with a single Main.wo component does not require me to do this. I think the javac compiler is determining the encoding automatically and it does it wrong (maybe?). Nahh... that doesn't seem to make sense. The string is the same "José" in the .java file in both projects.

The puzzle continues.  At least I have a workaround.

I do know now that the problem had nothing to do with embedding frameworks in the application. The problem is that when building from the command line the javac compiler is compiling the .java file as MacRoman. But why???? :-)







On Mar 19, 2009, at 5:46 PM, Ricardo J. Parada wrote:


On Mar 19, 2009, at 5:39 PM, Q wrote:

What encoding does your .java file have? And when it doesn't work, how was that .java file compiled?

.java files should ALWAYS be UTF-8, because that's what javac expects, however eclipse doesn't care. My gut feel is that your .java file is MacRoman and when eclipse compiles the class it works, and when javac compiles the class it doesn't.

Yep... I'm leaning towards that too.  Here's why:

There are two directories. The "build" directory and the "dist" directory. The compiled class in the "build" directory has the correct characters when I look at it with the decompiler (JD-GUI).

But when I look at the compiled class in the "dist" directory which is where it gets placed when I run ant from the command line, then the characters look wrong in JD-GUI.

So I'm gonna be looking at how the compiler gets told what encoding to use. Does anybody know?


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/rparada%40mac.com

This email sent to [email protected]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to