Thanks ArKay ( although it's not very encouraging
).
I've stepped through wxWidgets source and I *think* it comes down to the function:
Code: Select all
inline static void OutputString(wxOutputStream& stream, const wxString& str,
wxMBConv *convMem = NULL,
wxMBConv *convFile = NULL)
in C:\wxWidgets-2.8.7\src\xml\xml.cpp.
In this code:
Code: Select all
#if wxUSE_UNICODE
wxUnusedVar(convMem);
const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
stream.Write((const char*)buf, strlen((const char*)buf));
"convFile" is NULL for parameter
names.
Therefore, the line
Code: Select all
const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
uses wxConvUTF8 for conversion.
For parameter
values, however, convFile points to a UTF-16 converter. That's got to be it.
When the "wxWX2MBbuf" object is created with the UTF-16 converter, the call
returns "1". That explains why there's only 1 character written out.
I can make everything work by setting the file encoding to UTF-8 right before I save:
Code: Select all
finalParamXML.SetFileEncoding( wxT("UTF-8") );
Of course, I wind up with a UTF-8 XML file and not a UTF-16 file like I originally started out with.
Can anyone explain this behavior?
I'm really not up on my UTF-8 / UTF-16 / wxString conversions.
-Tim