Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Character encoding problem

 
Syam Sathyan George
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Client was testing one of the apps we delivered recently.

The app uses XML over HTTP, in MIDP2(cldc1.1).
Sony Erricson P990i and 800i were throwing weird Exceptions(Index Out of Bounds etc) while parsing the XML(the parser is a pull parser i wrote without DOM).
I traced the log and found that the Initial Characters are coming in english and after some reading from the stream the character are coming as squares and other unreadable characters, since no stack tracing in j2me for exceptions, i couldnt find out which line is throwing this, but suspects the string matches.

Can some one explain the reason behind this, the app works perfectly on many phones like Nokia's and Windows mobile OS phones!!!.

Conversion of character set, is it done automatically if we set the Content-encoding header on http requests??
[ November 08, 2007: Message edited by: Bear Bibeault ]
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syam Sathyan ,

Can you show me some of your code for the Encoding Part in your program?

regards
Khai Huat
 
Syam Sathyan George
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earlier i was converting the network recieved Bytes to String using
String xml=new String(byteArray);

Now i am Doing this ....
String encodedXml = new String(byteArray.getResponse(), 0, byteArray.length,"utf-8");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic