I'm using simpleFramework for parsing an xml file in my android app. My problem is in parsing french text like lets say this tag
The result I will receive when parsing is something like this "Ã©crite" This is encoding (french) problem in the simpleFramework xml. How can avoid that and have my text "écrite"
the xml header has utf8 :
<?xml version="1.0" encoding="UTF-8"?>Answer1:
I have hit this issue before whilst using a SAX parser. When reading the file with a Java
InputStream you need to specify the encoding of the stream in code- perhaps by reading the first line of the file as you have shown. Here is the code for assigning the encoding;
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); final SAXParser saxParser = saxParserFactory.newSAXParser(); // Note the encoding on the reader... final Reader reader = new InputStreamReader(<your file stream>, "UTF-8"); final InputSource inputSource = new InputSource(reader); inputSource.setEncoding("UTF-8"); saxParser.parse(inputSource, <some handler>);
Hope that helps. If not- post back with how you are reading the XML file.