Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResourceBunde in Unicode?

 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jane:

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

John.
 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic