21

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?

David Moles
  • 48,006
  • 27
  • 136
  • 235
  • I have no idea about IDEA, but why do you need a mixed-encoding source tree? Wouldn't converting all the files to UTF-8 make the life easier? – Paŭlo Ebermann Sep 09 '11 at 18:05
  • The files in question have to do with regex matching in foreign-language data with known encodings. It's easier and less error-prone to write the regex in the encoding you're matching against... or so I assume. (I'm new to this code base.) – David Moles Sep 12 '11 at 21:25
  • 1
    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.) – Paŭlo Ebermann Sep 12 '11 at 21:31

5 Answers5

38

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

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

obe6
  • 1,743
  • 15
  • 23
4

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>
Telebh
  • 305
  • 1
  • 4
  • 13
chc
  • 41
  • 1
3

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.

Community
  • 1
  • 1
Sonhja
  • 8,230
  • 20
  • 73
  • 131
3

Looks like a known bug.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
0

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.

Stabak
  • 36
  • 4