I am working on Android App for RSS reader. I have a problem when I am reading data from different URLs as there are several different character encodings used in the rss feeds, e.g. UTF-8 and ISO-8859-1.
I am using Volley StringRequest to read content from RSS and I am getting following Error for some RSS feeds..
BasicNetwork.performRequest: Unexpected response code 404 for http://khabar.ibnlive.com/rss/khabar/ghar-parivar/health.xml
This is the code I am using for UTF-8 in Parsing.
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= Build.VERSION_CODES.KITKAT) {
InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
xpp.setInput(stream, null);
}
else{
InputStream stream = new ByteArrayInputStream(response.getBytes(Charset.forName("UTF-8")));
xpp.setInput(stream, null);
}
The code is working fine with UTF-8 charset URLs like http://www.oneindia.com/rss/feature-fb.xml but showing above error with ISO-8859_1 supporting urls.
I have to read data from multiple RSS feeds so can anyone help me please to detect these charset and how can I convert these to UTF-8 charset or you can suggest any better option for this task.