problem converting from UTF8 to ISO8859_1
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sashank_rao
Posted On:   Monday, May 20, 2002 12:57 AM

Hi, I am converting a variable from UTF-8 to ISO8859_1 using - String cat[] = null; cat = request.getParameterValues("var1"); String catName = new String(cat[i].getBytes("UTF8"),"ISO8859_1"); The problem I face is, on conversion, catName has a whole lot of "??????" prefixed to the actual value. Why do the prefixed question marks appear and how do I do away with the same to get the actual converted value ? Shall be really thankful for all the suggestions provided.    More>>


Hi, I am converting a variable from UTF-8 to ISO8859_1 using -



String cat[] = null;

cat = request.getParameterValues("var1");



String catName =
new String(cat[i].getBytes("UTF8"),"ISO8859_1");



The problem I face is, on conversion, catName has a whole lot of "??????" prefixed to the actual value.



Why do the prefixed question marks appear and how do I do away with the same to get the actual converted value ?



Shall be really thankful for all the suggestions provided.

   <<Less

Re: problem converting from UTF8 to ISO8859_1

Posted By:   sashank_rao  
Posted On:   Thursday, May 23, 2002 01:50 AM

Firstly, Thanks for looking into my problem.



Also, the extra question marks were being prefixed because I was executing request.setCharacterEncoding("ISO8859_1")twice.



I commented out one of the request.setCharacterEncoding("ISO8859_1") from an earlier jsp page and then I was returned the correct value.



Thanks once again.

Re: problem converting from UTF8 to ISO8859_1

Posted By:   timj_das  
Posted On:   Tuesday, May 21, 2002 06:55 AM

I guess the String byte array u are getting using cat[i].getBytes("UTF-8") is not returing the bytes correctly, so the conversion in the next step is messed up.
Try using new String(cat[i].getBytes(), "ISO-8859-1");

Hope this helps!

:p
About | Sitemap | Contact