title: XercesC setting output to UTF-8
body: <p>I'm using XercesC Lib to create a serialization of my data. How can I set it to UTF-8? It is always generated with UTF-16 and I can't find a way to change that.</p>
  
  <pre><code>xercesc::DOMImplementation *gRegistry = xercesc::DOMImplementationRegistry::getDOMImplementation(X("Core"));
  xercesc::DOMDocument *doc = gRegistry-&gt;createDocument(
          0,                      // root element namespace URI.
          X(oDocumentName.c_str()),       // root element name
          0);                 // document type object (DTD).
  doc-&gt;setXmlStandalone(true);
  ... prepare the document ...
  serializer = ((xercesc::DOMImplementationLS *)gRegistry)-&gt;createLSSerializer();
  serializer-&gt;setNewLine(xercesc::XMLString::transcode("\n"));
  
  XMLCh *xmlresult = serializer-&gt;writeToString(doc);
  char *temp = xercesc::XMLString::transcode(xmlresult);
  std::string result(temp);
  
  xercesc::XMLString::release(&amp;temp);
  xercesc::XMLString::release(&amp;xmlresult);
  doc-&gt;release();
  serializer-&gt;release();
  getStream() &lt;&lt; result.c_str();
  </code></pre>
  
  <p>When I deserialize with JAXB on the Java side, I always get a <code>content is not allowed in prolog</code> and so far this is the only difference I can see in the XML. When I try to locally deserialze in JAXB it works. When I take my XercesC XML I get this error. When I try to format it in Notepad++ with the XML plugin it also says that there is an error, but doesn't tell me any details.</p>