]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xml/xml.cpp
respect wxBU_NOTEXT style in wxButton
[wxWidgets.git] / src / xml / xml.cpp
index 0193e5a8591c9ae56702c1394215f6a42e9b31d7..a37225c3dd7c7af074c02f35b69d5b1af23bca45 100644 (file)
@@ -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 )
     {
@@ -825,10 +831,11 @@ bool OutputStringEnt(wxOutputStream& stream,
     {
         wxChar c = str.GetChar(i);
         if (c == wxS('<') || c == wxS('>') ||
-            (c == wxS('&') && str.Mid(i+1, 4) != wxS("amp;")) ||
+            (c == wxS('&') && str.substr(i+1, 4) != wxS("amp;")) ||
             ((flags & XML_ESCAPE_QUOTES) && c == wxS('"')))
         {
-            if ( !OutputString(stream, str.substr(last, i), convMem, convFile) )
+            if ( !OutputString(stream, str.substr(last, i - last),
+                               convMem, convFile) )
                 return false;
 
             const char *escaped;
@@ -858,7 +865,7 @@ bool OutputStringEnt(wxOutputStream& stream,
         }
     }
 
-    return OutputString(stream, str.substr(last, i), convMem, convFile);
+    return OutputString(stream, str.substr(last, i - last), convMem, convFile);
 }
 
 bool OutputIndentation(wxOutputStream& stream,