Sometime, when you actually have to write internationalized software, you may run into difficulties with those damned ResourceBundles, and their bastard progeny, the PropertyResourceBundle.
According to the documentation, "(c)onstructing a PropertyResourceBundle instance from an InputStream requires that the input stream be encoded in ISO-8859-1."
If you end up with non-ISO-8859-1 characters in your bundle (e.g., SimplifiedChinese and Japanese), all is not lost. The little trick I stole from this guy could save you an awful lot of grief:
public String getProperty(String key)
{
ResourceBundle bundle = getResourceBundle();
String value = bundle.get(key);
byte[] bytes = value.getBytes("ISO-8859-1");
return new String(bytes, "utf-8");
}
No comments:
Post a Comment