title: StAX - writeCharacters(), how to not escape Chinese,Japanese characters?
body: <p>XMLStreamWriter#writeCharacters(...) </p>
  
  <p>The writeCharacters(...) method is used to escape characters such as &amp;, &lt;, >, and ". 
  (from   <a href="http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/StAX4.html" rel="nofollow">http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/StAX4.html</a>)</p>
  
  <p>but when I write some Chinese, Japanese characters, and the output XML
  file is not encoded in "UTF-8", but is "GBK" or "Shift-JIS". The Chinese, Japanese characters is also escaped, just like </p>
  
  <p>"汉语, English, にほんご"  --->  "&amp;#x6c49;&amp;#x8bed;, English, &amp;#x306b;&amp;#x307b;&amp;#x3093;&amp;#x3054;"</p>
  
  <p>Is there anyway to resolve it?</p>
  
  <hr>
  
  <pre><code>public static void main(String[] args) throws Exception {  
      // GBK  
      System.out.println("JVM default charset = " + Charset.defaultCharset());  
  
      String s = "汉语, English, にほんご";  
  
      XMLOutputFactory output = XMLOutputFactory.newInstance();  
      output.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, false);  
  
      OutputStream out = new FileOutputStream("C:/aa.txt");  
      XMLStreamWriter writer = output.createXMLStreamWriter(out, "UTF-8");  
      // When output encoding is "UTF-8", result is something like:  
      // &lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;a&gt;汉语, English, にほんご&lt;/a&gt;  
  
      // When output encoding is "GBK", result is something like:  
      // &lt;?xml version='1.0' encoding='GBK'?&gt;&lt;a&gt;&amp;#x6c49;&amp;#x8bed;, English, &amp;#x306b;&amp;#x307b;&amp;#x3093;&amp;#x3054;&lt;/a&gt;  
  
      writer.writeStartDocument();  
      writer.setDefaultNamespace("http://c");  
      writer.writeStartElement("http://c", "a");  
  
      writer.writeCharacters(s);  
      writer.writeEndElement();  
      writer.flush();  
  }  
  </code></pre>