]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
adaptions for m_peer
[wxWidgets.git] / src / common / string.cpp
index 9a0cff0e00abae665a9c6ea6617490ec3d615cfa..70473982fdcaec8055814ff41f2174964001c95a 100644 (file)
@@ -407,6 +407,20 @@ bool wxStringBase::Alloc(size_t nLen)
   //else: we've already got enough
   return TRUE;
 }
+  
+wxStringBase::iterator wxStringBase::begin()
+{
+    if (length() > 0)
+        CopyBeforeWrite();
+    return m_pchData;
+}
+
+wxStringBase::iterator wxStringBase::end()
+{
+    if (length() > 0)
+        CopyBeforeWrite();
+    return m_pchData + length();
+}
 
 wxStringBase::iterator wxStringBase::erase(iterator it)
 {
@@ -970,9 +984,14 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
         }
         else
         {
-            wxWCharBuffer buf(nLen + 1);
+            // the input buffer to MB2WC must always be NUL-terminated
+            wxCharBuffer inBuf(nLen);
+            memcpy(inBuf.data(), psz, nLen);
+            inBuf.data()[nLen] = '\0';
+
+            wxWCharBuffer buf(nLen);
             // MB2WC wants the buffer size, not the string length hence +1
-            nLen = conv.MB2WC(buf.data(), psz, nLen + 1);
+            nLen = conv.MB2WC(buf.data(), inBuf.data(), nLen + 1);
 
             if ( nLen != (size_t)-1 )
             {