X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ca11abde117b55a0054588fcf138234f8172b98d..9ac71bef070f553f4ecef2c549dba33b10422f06:/src/common/strconv.cpp?ds=inline diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 516e0a6a7c..235194fe46 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -239,19 +239,16 @@ const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const return wxWCharBuffer((wchar_t *) NULL); } -const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *psz) const +const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const { - if (psz) - { - size_t nLen = WC2MB((char *) NULL, psz, 0); // return value excludes /0 - if (nLen == (size_t)-1) - return wxCharBuffer((char *) NULL); - wxCharBuffer buf(nLen); // this allocates nLen+1 - WC2MB((char *)(const char *) buf, psz, nLen+1); - return buf; - } - else - return wxCharBuffer((char *) NULL); + // return value excludes NUL + size_t nLen = pwz ? WC2MB((char *) NULL, pwz, 0) : (size_t)-1; + if (nLen == (size_t)-1) + return wxCharBuffer((const char *)NULL); + + wxCharBuffer buf(nLen); // this allocates nLen+1 + WC2MB((char *)(const char *) buf, pwz, nLen+1); + return buf; } // ---------------------------------------------------------------------------- @@ -908,23 +905,23 @@ static wxCharacterSet *wxGetCharacterSet(const wxChar *name) cset = NULL; } -#if wxUSE_FONTMAP - cset = new EC_CharSet(name); +#if defined(__WIN32__) && !defined(__WXMICROWIN__) + cset = new CP_CharSet(name); if ( cset->usable() ) return cset; delete cset; cset = NULL; -#endif // wxUSE_FONTMAP +#endif // __WIN32__ -#if defined(__WIN32__) && !defined(__WXMICROWIN__) - cset = new CP_CharSet(name); +#if wxUSE_FONTMAP + cset = new EC_CharSet(name); if ( cset->usable() ) return cset; delete cset; cset = NULL; -#endif // __WIN32__ +#endif // wxUSE_FONTMAP wxLogError(_("Cannot convert from encoding '%s'!"), name);