Unmappable character for encoding UTF-8
Hello,
Intellij version : 110.291
Maven version : 2.2.1
Intellij then I compile some classes output : "unmappable character for encoding UTF-8".
The encoding in my POM is set to CP1252. The project encoding (and even file encoding!!) in setting > File encodings is set to windows-1252. The checkbox autodetect UTF-encoded file is unchecked. The files in "error" are opened by Intellij with windows-1252.
So why do Intellij try to compile the file with UTF-8 ??? ?:|
Thanks for your help! :)
Nicolas
Please sign in to leave a comment.
If I set IDE encoding to windows-1252, Intellij now compiles correctly. But what is the consequence of that ?
IDE passes project encoding to Javac via '-encoding' command line argument.
So what is the purpose of File Encoding > Default Encoding associated to file / directory ?
Is it only for editing ?
Yes.
The issue is that only one encoding setting is provided for the compiler. It's not per file.
Alexander.
Why does it do this?
When I compile with ant on the command line, it works all fine, no errors.
I just upgraded from 10.5 to 11 and boom, I get this error again!
I sing the praises of IntelliJ to everyone I meet, but this is ridiculous.
Please tell me how I can IntelliJ to not do what it is doing and just build as if I executed javac XXX.java on the command line. Javac seem perfectly capable of detecting the encoding without the -encoding flag.
If you compile your class with javac without encoding, javac is using the default encoding of your platform.
Have you try to set the "IDE encoding" ?
The project encoding is set to UTF-8.
So any files I create I want encoded in UTF-8.
I have one file that is part of a 3rd party interface spec (just delivered in source form, no binaries) that is windows-1252. All the other files are UTF-8. I have setup the encoding for that one file to be windows-1252.
I have an ant script that builds everything and it works fine. I guess it is *not* passing -encoding flag to javac. However, IntelliJ passes -encoding flag for the project and javac thinks this file is UTF-8 when it isn't.
I guess what I'm looking for is a way to tell IntelliJ just to chill and not pass that -encoding flag. Does IntelliJ pass -encoding when the project encoding is set? Perhaps splitting that setting to says 'create files in this encoding' and 'check to pass that encoding to javac' or something.
I just don't understand why I can compile file on the command line (mixing UTF-8 and windows-1252 encoded files) fine, but it blows up in IntelliJ.
I make the assumption your default encoding platforme is windows-1252 (ie. your OS is windows).
In my opinion you UTF-8 files compile with windows-1252 because they doesn't contain special character. So they compile perfectly with ant and on the command line which use windows-1252 as the encoding sheme.
Intellij use UTF-8 and your 3rd party file contains windows-1252 character. So it doesn't compile.
To test my hypothesis, try to set the encoding of the java ant task.
I will test it when I get home.
Thanks!