This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes ResourceBunde in Unicode? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "ResourceBunde in Unicode?" Watch "ResourceBunde in Unicode?" New topic
Author

ResourceBunde in Unicode?

Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
Does it strike anyone as odd that the very class that is meant to solve the internationalization problem (ResourceBundle) does not speak Unicode?

Anyway, I found a patch for it here:
http://www.thoughtsabout.net/blog/archives/000044.html, But it still won't read my Unicode files correctly; everything is garbled. What am I doing wrong?


Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
I found this comment in PropertyResourceBundle:

* <strong>Note:</strong> PropertyResourceBundle can be constructed either
* from an InputStream or a Reader, which represents a property file.
* Constructing a PropertyResourceBundle instance from an InputStream requires
* that the input stream be encoded in ISO-8859-1. In that case, characters
* that cannot be represented in ISO-8859-1 encoding must be represented by
* <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.3">Unicode Escapes</a>,
* whereas the other constructor which takes a Reader does not have that limitation.


I don't want to unicode-escape. So, how do I instantiate ResourceBundle using the constructor which takes a Reader? I don't have a debuggable version of rt.jar (which is a whole separate question). All I can tell that the bunde is instantiated (using the wrong constructor) in ResourceBundle.Control inner class.

John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Jane:

Since ResourceBundle is abstract, why don't you extend it and create a UnicodeResourceBundle class?

John.
Jane Jukowsky
Ranch Hand

Joined: Mar 28, 2009
Posts: 145
John de Michele wrote:Jane:

Since ResourceBundle is abstract, why don't you extend it and create a UnicodeResourceBundle class?

John.


The example above is already trying to do that. However, the logic in ResourceBundle is kind of mind-boggling, and without an adequate debugger, finding an elegant hook without rewriting the whole thing does not appear to be easy. I am thinking of giving up on ResourceBundle altogether and implementing my own logic from scratch, unless someone here helps.

 
GeeCON Prague 2014
 
subject: ResourceBunde in Unicode?