]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
declare wxEVT_GRID_COL_MOVE event (which was defined but not declared in the header...
[wxWidgets.git] / include / wx / string.h
index 1de67ef9c56f11b4e52364e7a7d0dacafe2f16ad..8178d100d976309036b60a19a044075eaf1602c3 100644 (file)
@@ -1087,19 +1087,25 @@ public:
 
   void resize(size_t nSize, wxUniChar ch = wxT('\0'))
   {
+    const size_t len = length();
+    if ( nSize == len)
+        return;
+
 #if wxUSE_UNICODE_UTF8
-    if ( !ch.IsAscii() )
+    if ( nSize < len )
     {
-        size_t len = length();
-        if ( nSize == len)
-            return;
-        else if ( nSize < len )
-            erase(nSize);
-        else
-            append(nSize - len, ch);
+        // we can't use wxStringImpl::resize() for truncating the string as it
+        // counts in bytes, not characters
+        erase(nSize);
+        return;
     }
+
+    // we also can't use (presumably more efficient) resize() if we have to
+    // append characters taking more than one byte
+    if ( !ch.IsAscii() )
+        append(nSize - len, ch);
     else
-#endif
+#endif // wxUSE_UNICODE_UTF8
         m_impl.resize(nSize, (wxStringCharType)ch);
   }
 
@@ -2864,10 +2870,10 @@ typedef wxStringInternalBuffer                wxStringBuffer;
 typedef wxStringInternalBufferLength          wxStringBufferLength;
 #endif // !wxUSE_STL_BASED_WXSTRING && !wxUSE_UNICODE_UTF8
 
-#if wxUSE_UNICODE_UTF8 && !wxUSE_STL_BASED_WXSTRING
+#if wxUSE_UNICODE_UTF8
 typedef wxStringInternalBuffer                wxUTF8StringBuffer;
 typedef wxStringInternalBufferLength          wxUTF8StringBufferLength;
-#elif wxUSE_UNICODE // !wxUSE_UNICODE_UTF8 || wxUSE_STL_BASED_WXSTRING
+#elif wxUSE_UNICODE_WCHAR
 class WXDLLIMPEXP_BASE wxUTF8StringBuffer : public wxStringTypeBufferBase<char>
 {
 public:
@@ -2888,7 +2894,7 @@ public:
 
     DECLARE_NO_COPY_CLASS(wxUTF8StringBufferLength)
 };
-#endif // wxUSE_UNICODE_UTF8 && !wxUSE_STL_BASED_WXSTRING or not
+#endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR
 
 
 // ---------------------------------------------------------------------------