The attached example (EncodeTest.zip) demonstrates this. To run the example
1.) Edit the java.home property in the build.xml to match the location of your EAP 5 distribution
2.) run "ant deploy" to deploy the ear to the default server profile
3.) edit your $JBOSS_HOME/bin/run.conf to include the file.encoding by adding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
4.) Start the default profile: $JBOSS_HOME/bin/run.sh
5.) From the example project run "ant run" With UTF-8 the result is:
08:01:14,992 INFO [STDOUT] File Encoding: UTF-8
08:01:14,992 INFO [STDOUT] Expect true: true
08:01:14,992 INFO [STDOUT] Expect false: false
6.) Stop EAP, and edit run.conf to use the Cp1252 encoding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=Cp1252"
7.) Start the default profile and, from the example project, run "ant run". The output will be
08:02:31,584 INFO [STDOUT] File Encoding: Cp1252
08:02:31,584 INFO [STDOUT] Expect true: false
08:02:31,584 INFO [STDOUT] Expect false: true
The relevant test code used in the above is:
accent = (String)(new InitialContext().lookup("java:comp/env/utf8Character"));
System.out.println("File Encoding: " + System.getProperty("file.encoding"));
System.out.println("Expect true: " + accent.equals("é"));
System.out.println("Expect false: " + accent.equals("é"));
So, we see that when the file encoding is set to Cp1252, the file is read with the Cp1252 encoding instead of UTF-8, resulting in the incorrect translation of the accented character.