I have an Enum class in Java that contains the letter É:
public enum Types {
RÉSUMÉ
}
When trying to build the project, IntelliJ complains on the É sign:
error: illegal character: '\u2030'
RÉSUMÉ
^
I'm using Windows 10.
In the past, the same project was compiled and run with no problems on my computer. So it seems like something in the settings was changed that caused this.
There is no option to replace É with E
Any idea how to fix this?
EDIT
- The code used to run with JDK 11 and was upgraded to Java 17. Maybe it has something to do with it. Trying to downgrade the JDK of the project (Settings -> Build -> Gradle -> back to JDK 11) didn't help
Character set & encoding of Java source code files
As commented, likely your source code files were written with a character encoding other than UTF-8. Now your compiler is expecting UTF-8, and reading your source code as such.
This problem could occur for either of two reasons:
The main clue for this character encoding misreading hypothesis is that code point U+2030 is not the LATIN CAPITAL LETTER E WITH ACUTE character, nor is it the composition of an uppercase E followed by the accent. No, the code point 2030 in hex (8,240 in decimal) is PER MILLE SIGN:
‰.Java 18+ defaults to UTF-8
See JEP 400: UTF-8 by Default. To quote:
You can easily verify if this new default is the source of your problem. Go back to your old project, and specify UTF-8 for compiling. Again, quoting the JEP: