The last week I've been trying to figure out why some stream decoding my newly adopted application is doing was giving me some major encoding problems. Finally I figured out that the problem was that the JARs/WAR being built with Ant and deployed to the server were being compiled with the javac task using the encoding UTF-8 instead of the system default of CP1252.
This seems to be caused mainly by having many hard coded strings/chars for these special characters.
This was easily resolved by either of the following steps:
- changing the encoding for the eclipse project to be UTF-8 to match the byte code on the server
- setting the encoding for the javac task to be CP1252 to build the WAR file to match the client byte code
- and strangely enough just running Ant from the command prompt without designating any encoding.
So why is Ant in Eclipse changing to UTF-8? Is this configurable? Where do I configure it?
- Windows XP
- Eclipse 3.5
- Ant 1.7.1
- Java 1.6.0_11
How do I prevent the console from appearing when building a Windows SDL project with Eclipse?
How can I profile a JNI application using the Eclipse TPTP?
Break on exception in pydev
My workspace and projects are using the default settings..
Samples from Xpand -
UTF-8 to match the byte code on the server.I'm not sure what you mean by this - you mean the encoding of the source files, surely.
How do you develop JSF apps?
How well do Eclipse and Netbeans coexist?
The bytecode is a structured set of instructions; string literals built into the class files are always UTF-8..
Can IntelliJ create hyperlinks to the source code from log4j output?
Things possible in Eclipse that aren’t possible in IntelliJ? [closed]
I would use Unicode escape sequences to make my files more encoding-agnostic.
You can use tools like native2ascii or the java.nio.charset API to help with this..
This property is in the Resource page of the Properties dialog, available when right-clicking on a source folder.. When nothing is specified, the workspace wide default encoding is used.
It is configurable from withing the Window>Preferences dialog.. Hope this helps..
It's Windows, and the text file encoding configuration in Eclipse is set at the default (Cp1252).. Ant from the command-line does not throw a fit when compiling code with "strange" characters (e.g., í, ñ, ü).
But the same Ant task from inside Eclipse does.. I've had to configure the Ant task in Eclipse with this parameter in the JRE tab:.
The javac part of the Ant task works fine now..