Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android XmlPullParser UTF-8 problem

Tags:

android

xml

utf-8

I have an XML document built with

org.xmlpull.v1.XmlSerializer

This document contains following XML prolog

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>

When I try to parse this document using

import org.xmlpull.v1.XmlPullParser;

with following configuration code

XmlPullParser pullParser = Xml.newPullParser();
pullParser.setInput(theInputStream, "utf-8");

I get undecoded utf-8 strings when I call

String text = pullParser.getText();

So it seems that XmlPullParser in Android (I use 1.5) doesn't support utf-8. Did I miss something?

Thank you in advance.

like image 212
Andriy Zakharchuk Avatar asked Nov 06 '22 17:11

Andriy Zakharchuk


1 Answers

Not sure if it matter but can you try two things

  1. Use UTF-8 instead of lower case

And

  1. Try using pullParser.setInput(theInputStream); and seeing if the pullparser can determine the encoding on it's own.
like image 137
nickfox Avatar answered Nov 11 '22 12:11

nickfox