]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
font is only non default if it has non default field values
[wxWidgets.git] / src / common / string.cpp
index 42c3a74f40db07104ff73f79f300068239843f54..964324306b8c1817a44282e8df5ac4716eb3b7b2 100644 (file)
@@ -245,7 +245,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
     size_t nLen;
     if ( psz )
     {
-        // calculate the needed size ourselves or use a provide one
+        // calculate the needed size ourselves or use the provided one
         nLen = nLength == wxSTRING_MAXLEN ? conv.MB2WC(NULL, psz, 0) : nLength;
     }
     else
@@ -260,17 +260,22 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
         if ( !AllocBuffer(nLen) )
         {
             wxFAIL_MSG( _T("out of memory in wxString::wxString") );
-            return;
         }
-
-        // MB2WC wants the buffer size, not the string length
-        if ( conv.MB2WC(m_pchData, psz, nLen + 1) != (size_t)-1 )
+        else
         {
-            // initialized ok
-            m_pchData[nLen] = 0;
-            return;
+            // MB2WC wants the buffer size, not the string length hence +1
+            nLen = conv.MB2WC(m_pchData, psz, nLen + 1);
+
+            if ( nLen != (size_t)-1 )
+            {
+                // initialized ok, set the real length as nLength specified by
+                // the caller could be greater than the real string length
+                GetStringData()->nDataLength = nLen;
+                m_pchData[nLen] = 0;
+                return;
+            }
+            //else: the conversion failed -- leave the string empty (what else?)
         }
-        //else: the conversion failed -- leave the string empty (what else?)
     }
 
     Init();
@@ -286,7 +291,7 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength)
     size_t nLen;
     if ( pwz )
     {
-        // calculate the needed size ourselves or use a provide one
+        // calculate the needed size ourselves or use the provided one
         nLen = nLength == wxSTRING_MAXLEN ? conv.WC2MB(NULL, pwz, 0) : nLength;
     }
     else
@@ -301,16 +306,17 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength)
         if ( !AllocBuffer(nLen) )
         {
             wxFAIL_MSG( _T("out of memory in wxString::wxString") );
-            return;
         }
-
-        // WC2MB wants the buffer size, not the string length
-        if ( conv.WC2MB(m_pchData, pwz, nLen + 1) != (size_t)-1 )
+        else
         {
-            // initialized ok
-            return;
+            // WC2MB wants the buffer size, not the string length
+            if ( conv.WC2MB(m_pchData, pwz, nLen + 1) != (size_t)-1 )
+            {
+                // initialized ok
+                return;
+            }
+            //else: the conversion failed -- leave the string empty (what else?)
         }
-        //else: the conversion failed -- leave the string empty (what else?)
     }
 
     Init();
@@ -1007,6 +1013,10 @@ wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll)
   return uiCount;
 }
 
+#ifdef __WXWINCE__
+inline int isascii(wxChar c) { return (c >= 0) && (c <=127); }
+#endif
+
 bool wxString::IsAscii() const
 {
   const wxChar *s = (const wxChar*) *this;
@@ -1753,6 +1763,8 @@ wxString& wxString::replace(size_t nStart, size_t nLen,
 // ArrayString
 // ============================================================================
 
+#include "wx/arrstr.h"
+
 #if !wxUSE_STL
 
 // size increment = min(50% of current size, ARRAY_MAXSIZE_INCREMENT)