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
This commit is contained in:
Vadim Zeitlin 2007-07-24 15:20:52 +00:00
parent 4fdfe2f3ae
commit a2db25a143

View File

@ -354,14 +354,14 @@ const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const
if ( psz ) if ( psz )
{ {
// calculate the length of the buffer needed first // 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 ) if ( nLen != wxCONV_FAILED )
{ {
// now do the actual conversion // now do the actual conversion
wxWCharBuffer buf(nLen /* +1 added implicitly */); wxWCharBuffer buf(nLen - 1 /* +1 added implicitly */);
// +1 for the trailing NULL // +1 for the trailing NULL
if ( MB2WC(buf.data(), psz, nLen + 1) != wxCONV_FAILED ) if ( ToWChar(buf.data(), nLen, psz) != wxCONV_FAILED )
return buf; return buf;
} }
} }
@ -373,14 +373,11 @@ const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const
{ {
if ( pwz ) if ( pwz )
{ {
const size_t nLen = WC2MB(NULL, pwz, 0); const size_t nLen = FromWChar(NULL, 0, pwz);
if ( nLen != wxCONV_FAILED ) if ( nLen != wxCONV_FAILED )
{ {
// extra space for trailing NUL(s) wxCharBuffer buf(nLen - 1);
static const size_t extraLen = GetMaxMBNulLen(); if ( FromWChar(buf.data(), nLen, pwz) != wxCONV_FAILED )
wxCharBuffer buf(nLen + extraLen - 1);
if ( WC2MB(buf.data(), pwz, nLen + extraLen) != wxCONV_FAILED )
return buf; return buf;
} }
} }