This section provides a tutorial example showing how 'javac' processing Java source code files with CP1252 encoding.
In order to test the "native2ascii" tool, I wrote the following Java source code file: HelloUtf8.java
public class HelloUtf8 {
public static void main(String[] a) {
System.out.println("Hello world!");
System.out.println("世界你好!");
}
}
"HelloUtf8.java" contains a string of Chinese characters written in UTF-8 encoding.
When I tried to compile it, I got the following warning:
C:\herong>javac HelloUtf8.java
HelloUTF8.java:4: warning: unmappable character for encoding Cp1252
System.out.println("S+�t��S+�s�+n+?");
^
1 warning
The compiler used "Cp1252" as the default encoding to process the source file, HelloUtf8.java.
The last character of my Chinese string encoded in UTF-8 can not be mapped to any CP1252 character.
But the compiler did finish the compilation. The output HelloUtf8.class can still be executed in JVM:
But the last character was compiled as a question mark "?" character.
To fix this problem, you need to use the "native2ascii" tool - see the next section.