You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Korhonen, Kalle" <kk...@cisco.com> on 2005/04/20 20:11:55 UTC

UTF-8 support

Looks like the default MyFaces implementation uses the standard
PropertyResourceBundle, which uses the standard Properties class that in
turn assumes only Latin-1 as encoding of the property file. That
naturally breaks all the UTF-8 encoded double-byte characters in the
properties file. I definitely don't want to use native2ascii, which is
just too much hassle, but just simply encode my Properties files as
UTF-8.

I'm surprised that I seem to be the first person hitting this problem. I
search the mail archives for "utf*" but got nothing on this. I assume
and recall reading from some place that you could replace the default
ResourceBundle implementation, similarly to overriding other
configuration in JSF's pluggable architecture. Anybody done this and
care to share any samples?

Struts implements its own resource classes that deal with UTF-8 encoded
files properly. In fact, those classes are not even inherited or using
any of the ResourceBundle/Properties base classes. Anybody done an
adaptation of that code as a ResourceBundle? A few months ago, I looked
around quickly but couldn't find any easily available, does anyone know
if there are any?

Also, looks like HtmlResponseWriterImpl is encoding all characters out
of latin-1 as unicode character references. For performance reasons, I
don't think we should do that if the response stream specifies UTF-8 as
encoding. There might be other complications that need to be considered,
but I might file a bug on it later and patch it once I get the UTF-8
properties file working.

(A little off-topic) Finally, I could also consider 1.5 Java
Properties.loadFromXml(), but I'm a little hesitant to use it because of
possible performance penalties and because I don't really need xml
format. Don't really understand why Sun wouldn't just add support for
UTF-8 for Properties.load() and store() since it shouldn't break
anything. Anyway, anybody have any experience on loadFromXml and an
opinion on pros and cons of it? The technical writers have barely
wrapped their heads around the concept of parametrized resources, so I'm
afraid introducing xml into the soup is just more confusing.

Kalle