How to handle xml encoding from a downloaded file

+1 David Frenzel · January 14, 2016
I've been searching for this quite some time now but haven't really found a solution. 

I'm downloading an xml file from a server and save it to my internal storage to then parse the data from it. Unfortunately the encoding of the document is ISO-8859-1. Since the document contains characters like ü, ö, ä it displays them as ? in the app. If I manually edit the encoding to utf-8 it works like a charm. 
So I somehow need to change this encoding in my downloaded file.. any help is greatly appreciated!!

Post a Reply


Oldest  Newest  Rating
0 David Frenzel · January 15, 2016
It took me a while but what did it was: 

FileInputStream fis = context.openFileInput("temp.xml");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fis, "ISO-8859-1")); // set enconding!!

You can also define the encoding in the setInput() method but then you can't use a BufferedReader - you need to pass in an InputStream as your first argument. 
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator