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

31,806

Solution 1

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

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

Solution 2

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>

Solution 3

Looks like a known bug.

Solution 4

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.

Share:
31,806

Related videos on Youtube

prashant
Author by

prashant

David Moles writes code for money and sometimes for fun.

Updated on July 09, 2022

Comments

  • prashant
    prashant almost 2 years

    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?

    • Paŭlo Ebermann
      Paŭlo Ebermann over 12 years
      When the strings are in memory, they are UTF-16 anyway, independent of the encoding the files were in (assuming you compiled them right). So while I can see why these files were created in these encodings, there is nothing speaking against converting them now. (Of course, you can also try to get the IDEA bug fixed.)
  • prashant
    prashant over 12 years
    I've got a single-module project, so if that bug is accurately reported, I think I'm looking at something different.
  • CrazyCoder
    CrazyCoder over 12 years
    You can file a separate issue and attach a sample project so that we can investigate it.

Related