David Moles
David Moles

Reputation: 51189

Intellij IDEA: "unmappable character for encoding UTF-8" compiling ISO-8859-1 files

I have a mixed-encoding source tree and I'm getting the warning above for some of my source files. I managed to sucessfully set the encoding for those files to ISO 8859-1 and, after invalidating IDEA's caches, they now display correctly in the editor. However, when I compile, I still get the error message.

Production builds use ant and it's not an issue there, but it means I can't "make" in the IDE. Is there a way to get IDEA to compile these correctly, or failing that, drop the error down to a warning?

Upvotes: 21

Views: 48400

Answers (6)

iDevSpread
iDevSpread

Reputation: 301

Change "Javac" to "Eclipse" in Java Compiler

I met the same error message, and tried the methods above that did not work well for me.

But I change the setting in Compiler. In the panel "Use compiler", click and choose Eclipse.

Done.

Upvotes: 0

Sonhja
Sonhja

Reputation: 8458

If you are using Intellij, the fastest way for me was:

File -> File Properties-> File encoding

and choose the one you want, in this case ISO-8859-1.

Upvotes: 3

Stabak
Stabak

Reputation: 36

Solution tested in IntelliJ 2019.3

Open the troublesome file. Go to File -> File Encoding. (You also have a quick option at the bottom right) Select the encoding you want. In my case it was UTF-8. Click on Convert when it prompts you if you want to convert the file in new encoding and overwrite the contents.

Try to compile. You should be able to compile fine.

Upvotes: 0

chc
chc

Reputation: 41

I have UTF-8 encoding in encoding.xml as follows, but still not working. keeps getting error "Error: java: error: unmappable character (0xFE) for encoding UTF-8"

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
    <file url="file://$PROJECT_DIR$" charset="UTF-8" />
    <file url="PROJECT" charset="UTF-8" />
  </component>
</project>

Upvotes: 4

obe6
obe6

Reputation: 1901

I solved this issue adding this property in IntelliJ option panel Compiler/Java Compiler :

Additional command line parameters : -encoding ISO-8859-1

Upvotes: 38

CrazyCoder
CrazyCoder

Reputation: 402453

Looks like a known bug.

Upvotes: 3

Related Questions