achelis
June 19th, 2008, 09:33 AM
Hi.
I need to read an xml-file in Java that's encoded with ISO-8859-1. Parsing the file is not a problem, but special characters are not decoded correctly. I have checked with a hex editor and the input file is correctly encoded.
Here is a peace of the code I use to create my Reader:
FileInputStream fis = new FileInputStream(xmlFile);
InputStreamReader isr = new InputStreamReader(fis,Charset.forName("ISO-8859-1"));
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.setErrorHandler(handler);
xmlReader.parse(new InputSource(isr));
I need to read an xml-file in Java that's encoded with ISO-8859-1. Parsing the file is not a problem, but special characters are not decoded correctly. I have checked with a hex editor and the input file is correctly encoded.
Here is a peace of the code I use to create my Reader:
FileInputStream fis = new FileInputStream(xmlFile);
InputStreamReader isr = new InputStreamReader(fis,Charset.forName("ISO-8859-1"));
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.setErrorHandler(handler);
xmlReader.parse(new InputSource(isr));