I have an encoding problem in Eclipse (Indigo Service Release 1). Here's what happens:
I have a property file (language bundle) in German language and it is not displayed correctly when I open it in Eclipse
. For instance: gelöscht
is displayed as gel�scht
. I have tried changing the File Association to Text Editor
, Properties File Editor
, JBoss Tools Properties Editor
but it is shown like this in all cases.
The interesting part is that when I open the file in Notepad++
it is displayed correctly.
In Eclipse
, the text file encoding is set to UTF-8
, and the encoding of the file (according to Notepad++
) is ANSI.
Is there another setting I do not know about? How can I fix this problem to see the correct encoding in Eclipse
?
How are you reading the properties files? Storing them in any non-ASCII encoding other than ISO-8859-1 (the default encoding expected by various bits of infrastructure) or UTF-8 sounds like a bad idea to me. I would strongly recommend that you stick to either ASCII, ISO-8859-1 or UTF-8.
These days you can load Properties
with any Reader
, but UTF-8 is usually the most appropriate encoding to use for files which need to cope with non-ASCII characters and work on any machine.
You can probably force Eclipse to think of it as using a difference encoding, by right-clicking on the file, selecting Properties, and then selecting a "Text file encoding" at the bottom of the Resources page - but I would suggest that you don't do that.
An alternative is to only use ASCII with appropriate \u....
escape sequences, as generated by native2ascii
.
(While you can include non-ASCII ISO-8859-1 characters, I personally wouldn't - it's obvious when characters aren't ASCII, but the distinction between ISO-8859-1 and other encodings gets trickier to spot with the naked eye.)