Welcome!

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

Reply
Contributor
Posts: 14
Registered: ‎11-22-2011
My Device: Bold 9790
My Carrier: wifi

Re: httpConnection/HttpConnectionFactory returning garbage while reading xml from server

[ Edited ]

Peter, here are two samples of corrupted bytes received today by a 8520 with OS 4.6:

 

??y????M?<

{...expected json response here...}

?<

 

This time, we got garbage not only on the beginning on the response, but on the end too. So I'm not sure if this is related to UTF-8 BOM.

 

Another one:

??j

??J????{"status","OK"}

 

This occurs only when device is connected with 3G, we did not reproduce over wifi.

Any idea?

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: httpConnection/HttpConnectionFactory returning garbage while reading xml from server

No sorry.

 

Can you dump off the bytes associated with this before you convert them to characters (String)?

 

In your current code you have this:

 

System.out.println("BYTE : " + new String(b));

 

We find out what the bytes are, by converting the bytes to 'hex', there is some sample code here:

 

http://supportforums.blackberry.com/t5/Java-Development/Showing-garbage-instead-of-Unicode-character...

 

After adding this method, you would replace the above with:

 

System.out.println("BYTEX : " + byteArrayToHex(b));