I have a project that runs correctly for quite a long time. Tow days ago, I updated my Eclipse version to Kepler's version and since then - my properties file are not being read correctly. Letters in Hebrew are being read like this: "××× ×©× ×שת×ש ×ס×ס××".
I though that somehow the files were ruined, so I copy-paste them to the simplest txt file and added to the project again. They are read correctly if I just simply read them, but they are not being read correctly if I continue to use the ResourceBundle implementation.
Does anyone have an idea of how to resolve this? I changed the platform and the file setting to utf-8 encoding - anywhere that I could think of...
This is the Resource code:
public class ResourceManager { protected final Logger logger = Logger.getLogger(this.getClass().getName()); public static final String FILE_PREFIX = "file::"; private static Locale locale = null; private static Map resourcesTable = new HashMap(); // Static initializer of the Local object - this currently return "iw" static { locale = new Locale(ApplicationConfiguration.getInstance().getProperty("user.language")); } /** * Return the Resources object according to the base name and Locale. */ private static Resources getResource(String baseName) { Resources resource = (Resources) resourcesTable.get(baseName); if (resource == null) { resource = new Resources(baseName, locale); resourcesTable.put(baseName, resource); } return resource; } //more code... /* This is the problematic method - but the problem starts even before when adding the resource to the resources map */ private static String getFormatedMessage(String baseName, String messageKey, Object... args) { Resources resource = getResource(baseName); String msg = null; if (args == null || args.length == 0) { msg = resource.getString(messageKey, ""); } else { msg = resource.format(messageKey, args); } return msg; } .... }
UTF-8
. They are defined to beiso-latin-1
and require all other non-latin characters to be written as\uxxxx
. They only way to workaround this is by using custom loading code but you would know if you used custom loading code and show us that code, wouldn’t you? – Holger