04-21-2010 02:37 AM
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?
04-21-2010 04:03 AM
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.