Showing ugly text when encoding type is UTF-8.

Hi friends,

I getting one strange problem while implementing UTF-8 encoding in I18N web application.

Following are the two keys in my

ApplicationResources.properties

=========================

text1= Ж

text2= informa珲es

=========================

* My ApplicationResources.properties file 's encoding type is UTF-8

Approach 1:

Code inside JSP file

=========================

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8" >

<tr>

<td > text1: <bean:message key="text1"/></td>

</tr>

<tr>

<td > text2: <bean:message key="text2"/></td>

</tr>

=========================

Output is which is not matching to wht we have specified in ApplicationResources

=========================

text1: 袞

text2: informa莽玫es

=========================

Approach 2:

When I used following code in JSP the out put looks ok

ResourceBundle re = ResourceBundle.getBundle("properties.ApplicationResources");

String strTemp = re.getString("text1");

String str1 = new String(strTemp.getBytes("ISO-8859-1"), "UTF-8");

strTemp = re.getString("text2");

String str2 = new String(strTemp.getBytes("ISO-8859-1"), "UTF-8");

<tr>

<td><%="text1 : "+str1%></td>

</tr>

<tr>

<td><%="text2 : "+str2%></td>

</tr>

Output is

=========================

text1: Ж

text2: informa珲es

=========================

I want above out put withApproach 1 (with I18N)

Please suggest me some way to solve this problem.

Waiting for the reply from the community.

Thanks & Regards,

Novin

[1998 byte] By [Novin-Jaiswala] at [2007-10-3 8:41:30]
# 1

Do you set the locale using a taglib directive? If you use a servlet version prior to 2.4, that might cause your encoding to be inferred from the locale (see: http://www.inter-locale.com/codeset1.jsp and http://lists.w3.org/Archives/Public/www-international/2004JulSep/0027.html).

For your Cyrillic character to display correctly the entry in the properties file should be encoded with ASCII escapes (run native2ascii), but since your 8859-1 characters also exhibit the problem, that cannot be the entire issue.

one_danea at 2007-7-15 3:49:49 > top of Java-index,Desktop,I18N...