Why does Eclipse display UTF-8 encoded files differently?

629 Views Asked by At

Eclipse is configured to interpret text files as UTF-8 encoding. Why does it not honor these settings in the Editor for *.properties files?

A text file named db.properties contains the 2-byte copyright character (302 251 octal). The file appears to be interpreted as ASCII (or ISO-8859-1) instead of UTF-8 as configured...

$ od -bc db.properties | head -2
0000000   043 040 103 157 160 171 162 151 147 150 164 040 302 251 040 062
           #       C   o   p   y   r   i   g   h   t       ©  **       2

Here is a screenshot of the Eclipse editor with this file loaded.

enter image description here

If the file is simply renamed to db.txt, the copyright symbol is displayed properly.

enter image description here

This suggests that Eclipse is treating .properties files differently than plain text files, configured to be interpreted as UTF-8. Is there a way to configure Eclipse to treat .properties files as UTF-8?

Platforms...

Mac OSX 10.15.7

Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)

Version: 2021-12 (4.22.0) Build id: 20211202-1639

1

There are 1 best solutions below

1
On BEST ANSWER

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

The default encoding appears as ISO-8859-1.

Default encoding can be changed there.