-    // if nLength != npos, then we have to make a NULL-terminated copy
-    // of first nLength chars of psz first because the input buffer to WC2MB
-    // must always be NULL-terminated:
-    wxWCharBuffer inBuf((const wchar_t *)NULL);
-    if (nLength != npos)
-    {
-        wxASSERT( pwz != NULL );
-        wxWCharBuffer tmp(nLength);
-        memcpy(tmp.data(), pwz, nLength * sizeof(wchar_t));
-        tmp.data()[nLength] = '\0';
-        inBuf = tmp;
-        pwz = inBuf.data();
-    }
-
-    // first get the size of the buffer we need
-    size_t nLen;
-    if ( pwz )
-    {
-        // calculate the needed size ourselves or use the provided one
-        nLen = conv.WC2MB(NULL, pwz, 0);
-    }
-    else
-    {
-        // nothing to convert
-        nLen = 0;
-    }
-