Search code examples
javafontscharacter-encodingresourcebundle

UTF-8Characters not displayed correctly in


we are working on a project for school, The project is mandatory tri-lingual (dutch, english and french) , so the answer "Change to English will not do".

All our classes and resource files are encoded in UTF-8 format, and alle non-standar english characters are diplayed correctly in the classes themself.

the problem is that once we try to display our text, alle non-standard english characters are distorted.

We hear alot that this is due to an encoding issue, but I sincerly doubt that, since our whole project is encode in UTF-8.

here is extract from the french resource bundle:

VIDEOSETTINGS = Réglages du Vidéo
SOUNDSETTINGS = Réglages du son
KEYBINDSETTINGS = Keybind Paramètres
LANGUAGESETTINGS = Paramètres de langue
DIFFICULTYSETTINGS = Paramètres de Difficulté
EXITSETTINGS = Sortie les paramètres

and this results in these following displayed strings.

display result for provided resourcebundle extract

I would be most gratefull for a solution for this problem

EDIT

for extra info we are building a desktop app using Swing.


Solution

  • You didn't show some code, where you read the resource files. But if you use PropertyResourceBundle with an InputStream in the constructor, the InputStream must be encoded in ISO-8859-1. In that case, characters that cannot be represented in ISO-8859-1 encoding must be represented by Unicode Escapes.

    You can use native2ascii or AnyEdit as tools to convert Properties to unicode escapes, see Use cyrillic .properties file in eclipse project