Converting UTF-8 to ISO-8859-1 in Java
I am reading an XML document (UTF-8) and ultimately displaying the content on a Web page using ISO-8859-1. As expected, there are a few characters are not displayed correctly, such as “ , – and ’ (they display as ?). Is it possible to convert these characters from UTF-8 to ISO-8859-1? Here is a snippet of code I have written to attempt this: BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); StringBuilder sb = new StringBuilder(); String line = null; while ((line = br.readLine()) != null) { sb.append(line); } br.close(); byte[] latin1 = sb