X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9c39f4f538b97bc595c31770947a49705e08aaf0..85284ca4b226d9a1ab6bed26c5eaa480543649d5:/src/xml/xml.cpp diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 1555d29b72..a37225c3dd 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -29,7 +29,7 @@ #include "wx/datstrm.h" #include "wx/zstream.h" #include "wx/strconv.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "expat.h" // from Expat @@ -783,12 +783,18 @@ bool OutputString(wxOutputStream& stream, #if wxUSE_UNICODE wxUnusedVar(convMem); + if ( !convFile ) + convFile = &wxConvUTF8; - const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8))); - if ( !buf ) + const wxScopedCharBuffer buf(str.mb_str(*convFile)); + if ( !buf.length() ) + { + // conversion failed, can't write this string in an XML file in this + // (presumably non-UTF-8) encoding return false; + } - stream.Write(buf, strlen(buf)); + stream.Write(buf, buf.length()); #else // !wxUSE_UNICODE if ( convFile && convMem ) {