Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 11
Registered: ‎04-09-2010
My Device: Curve-9000
My Carrier: AT&T

read & parse XML that contains unicode characters on blackberry

Hi All,


I am requesting XML data using HTTP request on my blackberry simulator. This XML contains some unicode characters.


Can i get those unicode symbols in XML file on blackberry simulator?? Do i need to change any encoding to read those characters?


One other question is that i want to parse this XML with unicode symbols. Can i parse this XML using SAXParser?




Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: read & parse XML that contains unicode characters on blackberry

You should have no problem with the SAX parser if the XML is encoded in UTF-8, especially if the encoding is included in the XML prolog. Just feed the input stream from the request directly into the parser's parse() function. (A typical mistake is to get the input stream from the HTTP connection, wrap it it an InputStreamReader, wrap that in an InputSource, and finally feed that to the parser. That's a lot of work for no gain.)


Also, you should be aware that the default encoding on the device is ISO-8859-1. Most functions that go between bytes and characters (like new String(byte[]) and String.getBytes()) have variant forms that allow you to specify the encoding, and UTF-8 encoding is supported on all BlackBerry OS versions. You should always specify the encoding explicitly when using any of these functions.

Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.