title: parsing non-ASCII character in XML document
body: <p>I'm trying to parse this XML document with a SAX parser:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!DOCTYPE WIN_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd"&gt;
  &lt;WIN_TPBOUND_MESSAGES&gt;
      &lt;SMSTOTP&gt;
          &lt;SOURCE_ADDR&gt;+447522579247&lt;/SOURCE_ADDR&gt;
          &lt;TEXT&gt;TEST: @£$¥èéùìò?ØøÅå&amp;amp; ^{}\\[~]¡&amp;#8364;ÆæßÉ!\"#¤%'()*+,-./0123456789:;&amp;lt;=&amp;gt;? ÄÖÑÜ§¿äöñüà end&lt;/TEXT&gt;
          &lt;WINTRANSACTIONID&gt;652193268&lt;/WINTRANSACTIONID&gt;
      &lt;/SMSTOTP&gt;
  &lt;/WIN_TPBOUND_MESSAGES&gt;
  </code></pre>
  
  <p>After parsing the <code>&lt;TEXT&gt;</code> element, the content is converted to:</p>
  
  <pre><code>TEST: @Â£$Â¥Ã¨Ã©Ã¹Ã¬Ã²?Ã�Ã¸Ã�Ã¥&amp; ^{}\\[~]Â¡€Ã�Ã¦Ã�Ã�!\"#Â¤%'()*+,-./0123456789:;&lt;=&gt;? Ã�Ã�Ã�Ã�Â§Â¿Ã¤Ã¶Ã±Ã¼Ã  end
  </code></pre>
  
  <p>So clearly something bad is happening to the non-ASCII characters. The code that parses the XML is shown below:</p>
  
  <pre><code>public void parse(InputStream xmlStream) throws WinGatewayException {
      XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
      parser.setContentHandler(this);
      parser.setErrorHandler(error);
      parser.setEntityResolver(new DTDResolver());
      parser.setDTDHandler(this);
      parser.setFeature("http://xml.org/sax/features/validation", true);
      parser.setFeature("http://apache.org/xml/features/validation/schema", true);
      parser.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", true);
      parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
      parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);
      parser.parse(new InputSource(xmlStream));
  }
  </code></pre>
  
  <p>and the object referred to by <code>this</code> has methods such as:</p>
  
  <pre><code>public void endElement(String uri, String localName, String qName)
          throws SAXException {
  
          if (localName.equals("TEXT")) {   
              logger.debug("Parsed message text: " + cData.toString());
              message.setText(cData.toString());
          }
  }
  </code></pre>
  
  <p>Why aren't these non-ASCII characters being preserved by the XML parser?</p>