Java Properties Utf-8 Encoding in Eclipse

Java properties UTF-8 encoding in Eclipse

Don't waste your time, you can use Resource Bundle plugin in Eclipse

Basic Screen Shot

Old Sourceforge page

Why does Eclipse display UTF-8 encoded files differently?

Look at
Preferences -> General -> Content types -> Java Properties File

The default encoding appears as ISO-8859-1.

Default encoding can be changed there.

Eclipse .properties file disable escaping of UTF-8 characters

Right Click on the file, properties. Under "resource" tab , check for "Text File Encoding" at the bottom right and change that to UTF-8.

How to make eclipse read bundle properties in UTF-8?

This is not supported. The code that reads the bundle properties file ends up using the PropertyResourceBundle class which always assumes ISO-8859-1

Java properties files localization & character encoding issue

There are two completely separate issues here:

  • Are the properties files saved in the correct encoding? If you edit them inside eclipse, you have to set the text file encoding in the project properties. Note that this setting is saved in the .settings subdirectory of the project.
  • Is the correct encoding used to read the properties files? If you read them in your code, be sure to use an InputStreamReader to set the encoding. If they're read by some framework, you have to look through its API and configuration to see whether you can specify the encoding.

I suggest avoiding the use of unicode escapes if at all possible.

UTF-8 encoding of application.properties attributes in Spring-Boot

As already mentioned in the comments .properties files are expected to be encoded in ISO 8859-1. One can use unicode escapes to specify other characters. There is also a tool available to do the conversion. This can for instance be used in the automatic build so that you still can use your favorite encoding in the source.



Related Topics



Leave a reply



Submit