0

I am facing some problem to show unicode characters in a jsp.

I have done as following

String s1="\u0985";
String s2=request.getParameter("str");

out.println("s1:=="+s1);
out.println("s2:=="+s2);

now when we are passing the same value (\u0985) as s1 to the s2.

output:

s1:==অ
s2:==\u0985

i want s1 and s2 give me the same output. Any help is highly appreciated

Santhosh
  • 8,181
  • 4
  • 29
  • 56
Ankan
  • 1
  • Couldnt get you . can you post the expected output? – Santhosh May 15 '14 at 06:49
  • I am passing \u0985 to the str by url. so s2 is getting \u0985. now s1 and s2 have the same value. so why the output are different. I want s1:==অ s2:==অ – Ankan May 15 '14 at 06:54
  • But you need `s2` to display like this `অ` . correct? – Santhosh May 15 '14 at 06:55
  • Can you post the code where you are passing `str`? – Santhosh May 15 '14 at 06:59
  • url is localhost:8080/testUnicode/displayUni.jsp?str=\u0985 – Ankan May 15 '14 at 07:03
  • Try this `String s2 = URLDecoder.decode(request.getParameter("str"), 'UTF-8');` in your jsp – Santhosh May 15 '14 at 07:07
  • You need to encode the URI as you are passing in the query string . see [this](http://stackoverflow.com/questions/4225206/problem-in-decoding-parameters-in-get-method-jsp) and [this](http://stackoverflow.com/questions/469874/how-do-i-correctly-decode-unicode-parameters-passed-to-a-servlet) examples. And also [read this](http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html) – Santhosh May 15 '14 at 07:34

0 Answers0