When I compile my web application using ant I get the following compiler message:
unclosed character literal
The line of offending code is:
protected char[] diacriticVowelsArray = { 'á', 'é', 'í', 'ó', 'ú' };
Wh开发者_JAVA百科at does the compiler message mean?
Java normally expects its source files to be encoded in UTF-8. Have you got your editor set up to save the source file using UTF-8 encoding? The problem is if you use a different encoding, then the Java compiler will be confused (since you're using characters that will be encoded differently between UTF-8 and other encodings) and be unable to decode your source.
It's also possible that your Java is set up to use a different encoding. In that case, try:
javac -encoding UTF8 YourSourceFile.java
Use UTF encoding for text files with your Java sources.
or
Use '\uCODE'
where CODE is Unicode number for á, é etc. (like for 'á'
you write '\u00E1'
).
You might need this:
http://www.fileformat.info/info/unicode/char/e1/index.htm
It worked for me to use "
instead of the '
char.
It also worked the javac -encoding UTF8
param as previously described.
This means that the compiler did not used the UTF8 coding.
精彩评论