]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxcrt.cpp
Add another test for the insertion point position after SetValue().
[wxWidgets.git] / src / common / wxcrt.cpp
index 55ad0812a89c2b22fd09deba2ab50e732689a280..dc51b48e41a7c00179e417ae63bf5bd8c9954dad 100644 (file)
@@ -586,13 +586,20 @@ namespace
 #if !wxUSE_UTF8_LOCALE_ONLY
 int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
 {
-    const wxWX2WCbuf buf = s.wc_str();
+    const wxCharBuffer buf(s.mb_str());
 
-    size_t len = wxConvLibc.FromWChar(out, outsize, buf);
-    if ( len != wxCONV_FAILED )
-        return len-1;
-    else
-        return wxConvLibc.FromWChar(NULL, 0, buf);
+    const size_t len = buf.length();
+    if ( outsize > len )
+    {
+        memcpy(out, buf, (len+1) * sizeof(char));
+    }
+    else // not enough space
+    {
+        memcpy(out, buf, (outsize-1) * sizeof(char));
+        out[outsize-1] = '\0';
+    }
+
+    return len;
 }
 #endif // !wxUSE_UTF8_LOCALE_ONLY