I have to display text in Hindi (or any regional language) on the browser screens. I will be getting this text from the database.
For this I started at a very basic level with the following:
String escapedStr = "\u0905\u092d\u0940 \u0938\u092e\u092f \u0939\u0948 \u091c\u0928\u0924\u093e";
String hindiText = StringEscapeUtils.unescapeJava(escapedStr);
System.out.println(hindiText);
return hindiText;
I am able to get the Hindi text perfectly fine in the variable hindiText
.
But when I print it on eclipse console or on the browser screen I get only ???? ?? ??
I set the default character encoding of my browser as well as my eclipse console to UNICODE(UTF-8). But still no success.
Can anyone help me solve this? What setting am I missing?
Just fyi - I am able to open hindi websites in my browser. So language settings is not an issue.
EDIT
As I am using JSP files for my views, I have added the following to my web.xml
for setting the character encoding globally. Ref: Followed this
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
But still no success!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…