From: Vadim Zeitlin Date: Tue, 24 Jul 2007 15:20:52 +0000 (+0000) Subject: use To/FromWChar() in single parameter wxMBConv::cMB2WC/WC2MB() overloads too, instea... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a2db25a1436b8363e4ccf98e3d43eee3a01b9cd7?ds=inline use To/FromWChar() in single parameter wxMBConv::cMB2WC/WC2MB() overloads too, instead of passing by the deprecated MB2WC/WC2MB() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 4d672fedfb..0f54c2821f 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -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; } }