- s = wxT("<?xml version=\"") + doc.GetVersion() +
- wxT("\" encoding=\"utf-8\"?>\n");
- OutputString(stream, s);
+ wxMBConv *convMem = NULL, *convFile = NULL;
+#if wxUSE_UNICODE
+ convFile = new wxCSConv(doc.GetFileEncoding());
+#else
+ if ( doc.GetFileEncoding() != doc.GetEncoding() )
+ {
+ convFile = new wxCSConv(doc.GetFileEncoding());
+ convMem = new wxCSConv(doc.GetEncoding());
+ }
+#endif
+
+ s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
+ doc.GetVersion().c_str(), doc.GetFileEncoding().c_str());
+ OutputString(stream, s, NULL, NULL);
+
+ OutputNode(stream, doc.GetRoot(), 0, convMem, convFile);
+ OutputString(stream, wxT("\n"), NULL, NULL);