Jerry Jacob's Blog

UTF-8: Encoding Fix

Posted in Java/ J2EE by jerlinworld on December 14, 2009

I was trying to get the non-ascii characters from my property file to render correctly in my jsp file. My original property file was encoded using UTF-8 with the spanish translations for my application. While rendering the page, I was getting a few garbled text instead of pulling the proper spanish text from the property file. Here is the simple fix that I came across after researching on it for the whole day.

1. Made a copy of my original property file, messages_es.properties, and named it messages_es.original.properties
2. Run the file, messages_es.original.properties, through native2ascii to convert the characters to its unicode escape form. Here is the command line for this: native2ascii -encoding UTF-8 ages_es.original.properties messages_es.properties

This fix for the property file resolved my issues.

For more info, you may visit, http://java.sun.com/developer/JDCTechTips/2003/tt0506.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: