]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
Patch from Bo for recent API changes
[wxWidgets.git] / src / common / strconv.cpp
index 4d672fedfb124af18c47b2927a4f7142f791954d..eeaa071f3101c348f9ca430390622019f19f5e87 100644 (file)
@@ -354,14 +354,14 @@ const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const
     if ( psz )
     {
         // calculate the length of the buffer needed first
-        const size_t nLen = MB2WC(NULL, psz, 0);
+        const size_t nLen = ToWChar(NULL, 0, psz);
         if ( nLen != wxCONV_FAILED )
         {
             // now do the actual conversion
-            wxWCharBuffer buf(nLen /* +1 added implicitly */);
+            wxWCharBuffer buf(nLen - 1 /* +1 added implicitly */);
 
             // +1 for the trailing NULL
-            if ( MB2WC(buf.data(), psz, nLen + 1) != wxCONV_FAILED )
+            if ( ToWChar(buf.data(), nLen, psz) != wxCONV_FAILED )
                 return buf;
         }
     }
@@ -373,14 +373,11 @@ const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const
 {
     if ( pwz )
     {
-        const size_t nLen = WC2MB(NULL, pwz, 0);
+        const size_t nLen = FromWChar(NULL, 0, pwz);
         if ( nLen != wxCONV_FAILED )
         {
-            // extra space for trailing NUL(s)
-            static const size_t extraLen = GetMaxMBNulLen();
-
-            wxCharBuffer buf(nLen + extraLen - 1);
-            if ( WC2MB(buf.data(), pwz, nLen + extraLen) != wxCONV_FAILED )
+            wxCharBuffer buf(nLen - 1);
+            if ( FromWChar(buf.data(), nLen, pwz) != wxCONV_FAILED )
                 return buf;
         }
     }
@@ -706,7 +703,7 @@ size_t wxMBConvUTF7::WC2MB(char *buf, const wchar_t *psz, size_t n) const
 // UTF-8
 // ----------------------------------------------------------------------------
 
-static wxUint32 utf8_max[]=
+static const wxUint32 utf8_max[]=
     { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff, 0xffffffff };
 
 // boundaries of the private use area we use to (temporarily) remap invalid
@@ -715,7 +712,7 @@ const wxUint32 wxUnicodePUA = 0x100000;
 const wxUint32 wxUnicodePUAEnd = wxUnicodePUA + 256;
 
 // this table gives the length of the UTF-8 encoding from its first character:
-unsigned char tableUtf8Lengths[256] = {
+const unsigned char tableUtf8Lengths[256] = {
     // single-byte sequences (ASCII):
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 00..0F
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 10..1F
@@ -2739,7 +2736,7 @@ void wxCSConv::SetName(const char *charset)
 {
     if (charset)
     {
-        m_name = strdup(charset);
+        m_name = wxStrdup(charset);
         m_deferred = true;
     }
 }