You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Vitor Rodrigues <vi...@mog-solutions.com> on 2003/06/09 16:28:00 UTC

problem serializing xml in UTF-16 format

Hi,
 
I’m using xerces 2.1 for c++ to build xml files in UTF-16 format and i
use the following code to serialize it,
 
DOMDocument* document_;
    
(...)
 
void serializeXML (const wchar_t* filePath)
    {
        DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation (L"LS");
        Templates::auto_ptr <DOMWriter> writer (((DOMImplementationLS*)
impl) -> createDOMWriter ());
 
        writer -> setNewLine (0);
        writer -> setEncoding (L"UTF-16");
        LocalFileFormatTarget myFormTarget (filePath);
        writer -> writeNode (&myFormTarget, *document_);            
    }
 
The problem is that this code does not enter the FF FE (ÿþ) code in the
top of the file. I presume that this is the code that determines, or
better, tells the reader that the file is UTF-16 coded. I’m also using
XMLSpy for editing. If I use it for something, for example, to assign a
schema, the saved file arrives with that code (FF FE) on the top. The
real problem is that I want to Explorer to read the file. It can only
show the file if the UTF-16 is present. Anyone knows a programmatic way
to include the UTF-16 inicial code in the generated xml file?
 
Thanks in advance,
 
Vitor Rodrigues