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

