git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53870
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
char* bufPtr = (char*)dst;
// have destination buffer, convert there
char* bufPtr = (char*)dst;
// have destination buffer, convert there
+ size_t dstLenOrig = dstLen;
cres = iconv(m2w,
ICONV_CHAR_CAST(&pszPtr), &srcLen,
&bufPtr, &dstLen);
cres = iconv(m2w,
ICONV_CHAR_CAST(&pszPtr), &srcLen,
&bufPtr, &dstLen);
- res = dstLen - (dstLen / SIZEOF_WCHAR_T);
+
+ // convert the number of bytes converted as returned by iconv to the
+ // number of (wide) characters converted that we need
+ res = (dstLenOrig - dstLen) / SIZEOF_WCHAR_T;
for ( unsigned i = 0; i < res; i++ )
dst[i] = WC_BSWAP(dst[i]);
}
for ( unsigned i = 0; i < res; i++ )
dst[i] = WC_BSWAP(dst[i]);
}
-
- // NUL-terminate the string if there is any space left
- if (res < dstLen)
- dst[res] = 0;
}
else // no destination buffer
{
}
else // no destination buffer
{