cMB2WX and cWX2MB accepts null pointers.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2269 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven
1999-04-24 12:21:03 +00:00
parent c96faa7c9b
commit d9e89b159c

View File

@@ -176,17 +176,21 @@ class WXDLLEXPORT wxMBConv
virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const;
const wxWCharBuffer cMB2WC(const char *psz) const const wxWCharBuffer cMB2WC(const char *psz) const
{ {
size_t nLen = MB2WC((wchar_t *) NULL, psz, 0); if (psz) {
wxWCharBuffer buf(nLen); size_t nLen = MB2WC((wchar_t *) NULL, psz, 0);
MB2WC(WCSTRINGCAST buf, psz, nLen); wxWCharBuffer buf(nLen);
return buf; MB2WC(WCSTRINGCAST buf, psz, nLen);
return buf;
} else return wxWCharBuffer((wchar_t *) NULL);
} }
const wxCharBuffer cWC2MB(const wchar_t *psz) const const wxCharBuffer cWC2MB(const wchar_t *psz) const
{ {
size_t nLen = WC2MB((char *) NULL, psz, 0); if (psz) {
wxCharBuffer buf(nLen); size_t nLen = WC2MB((char *) NULL, psz, 0);
WC2MB(MBSTRINGCAST buf, psz, nLen); wxCharBuffer buf(nLen);
return buf; WC2MB(MBSTRINGCAST buf, psz, nLen);
return buf;
} else return wxCharBuffer((char *) NULL);
} }
#if wxUSE_UNICODE #if wxUSE_UNICODE
const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); }