]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/oleutils.cpp
split wxEVT_GRID_CELL_CHANGE into wxEVT_GRID_CELL_CHANGING/ED pair for consistency...
[wxWidgets.git] / src / msw / ole / oleutils.cpp
index c596c2bc1cf6ac4dbee8d48c21524a27d1d46253..94f134a097af38981513e4182471ff32c946d50f 100644 (file)
@@ -80,19 +80,22 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
     if ( !bStr )
         return wxString();
 
+    const int len = SysStringLen(bStr);
+
 #if wxUSE_UNICODE
-    wxString str(bStr);
+    wxString str(bStr, len);
 #else
     wxString str;
-    const int len = SysStringLen(bStr) + 1;
-    if ( !::WideCharToMultiByte(CP_ACP, 0 /* no flags */,
-                                bStr, len,
-                                wxStringBuffer(str, len), len,
-                                NULL, NULL /* no default char */) )
+    if (len)
     {
-        str.clear();
+        wxStringBufferLength buf(str, len); // asserts if len == 0
+        buf.SetLength(WideCharToMultiByte(CP_ACP, 0 /* no flags */,
+                                  bStr, len /* not necessarily NUL-terminated */,
+                                  buf, len,
+                                  NULL, NULL /* no default char */));
     }
 #endif
+
     return str;
 }