[android-beginners] Re: XML stream corruption
Hi, I found what's wrong. The Dalvik VM doesn't handle unicode in xml very well. Here's a bug report http://code.google.com/p/android/issues/detail?id=2607 As I understand the last message in the bug tracker, they have assigned it to be fixed to the next version of Android. Regards, Peter On 7 Dec, 10:19, Peter Lundgren wrote: > Hi! > I am writing a client on Android for a "corporate twitter" system. I > have written the http-request/response handling in Java on windows > first, and migrated the source to my Android project once I saw it > work. No changes seemed to have to be done to the source, it compiled > nicely. > > However, since our users are swedish we have a heavy use of umlauts in > the "twitter" messages, and the messages received in the xml from the > server becomes corrupted at the first umlaut. At first I thought it > was something with the TextView widget, but it turned out I can hard > code a swedish sentence and it is printed correctly in the TextView. > None of this is problem in Java SE on windows, but the strings seems > to be corrupted when read from the httpClient in Android. > > I collect the xml text this way: > > public myResponse handleResponse( HttpResponse response ) throws > ClientProtocolException, IOException > { > HttpEntity entity = response.getEntity(); > BufferedReader reader = null; > StringBuffer buffer = new StringBuffer(); > String inputLine = null; > YammerResponse messageResponse = null; > > if (entity != null) > { > reader = new BufferedReader( new InputStreamReader > ( entity.getContent(), "UTF-8" )); > > while( (inputLine = reader.readLine()) != null ) > { > buffer.append( inputLine ); > } > > messageResponse = new ResponseParser().parseString > ( buffer.toString()); > } > > System.out.println( "Response parsed! "); > > return messageResponse; > } > > I would appreciate some help here! > > Regards, > Peter -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: XML stream corruption
I also tried now, to get a little fewer steps in the process, to pass the stream directly to the xml DOM document builder. This should certainly handle the encoding for me, but unfortunately, I get no change. On 7 Dec, 10:19, Peter Lundgren wrote: > Hi! > I am writing a client on Android for a "corporate twitter" system. I > have written the http-request/response handling in Java on windows > first, and migrated the source to my Android project once I saw it > work. No changes seemed to have to be done to the source, it compiled > nicely. > > However, since our users are swedish we have a heavy use of umlauts in > the "twitter" messages, and the messages received in the xml from the > server becomes corrupted at the first umlaut. At first I thought it > was something with the TextView widget, but it turned out I can hard > code a swedish sentence and it is printed correctly in the TextView. > None of this is problem in Java SE on windows, but the strings seems > to be corrupted when read from the httpClient in Android. > > I collect the xml text this way: > > public myResponse handleResponse( HttpResponse response ) throws > ClientProtocolException, IOException > { > HttpEntity entity = response.getEntity(); > BufferedReader reader = null; > StringBuffer buffer = new StringBuffer(); > String inputLine = null; > YammerResponse messageResponse = null; > > if (entity != null) > { > reader = new BufferedReader( new InputStreamReader > ( entity.getContent(), "UTF-8" )); > > while( (inputLine = reader.readLine()) != null ) > { > buffer.append( inputLine ); > } > > messageResponse = new ResponseParser().parseString > ( buffer.toString()); > } > > System.out.println( "Response parsed! "); > > return messageResponse; > } > > I would appreciate some help here! > > Regards, > Peter -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en