X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0f0298b10cc3d4f862e764fcabffce6f426c91a8..c1dda21b64f300d89cbc084802082d37c694e971:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index bd0a0926c3..2fd2d740b3 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -16,9 +16,6 @@ #include "wx/wxprec.h" #ifndef WX_PRECOMP - #ifdef __WXMSW__ - #include "wx/msw/missing.h" - #endif #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" @@ -29,10 +26,6 @@ #if wxUSE_WCHAR_T -#ifdef __WINDOWS__ - #include "wx/msw/private.h" -#endif - #ifndef __WXWINCE__ #include #endif @@ -42,6 +35,8 @@ #include #if defined(__WIN32__) && !defined(__WXMICROWIN__) + #include "wx/msw/private.h" + #include "wx/msw/missing.h" #define wxHAVE_WIN32_MB2WC #endif @@ -3650,9 +3645,39 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = & #else wxConvUTF8Obj; #endif -#else +#else // !__WXOSX__ wxConvLibcObj; -#endif +#endif // __WXOSX__/!__WXOSX__ + +#if wxUSE_UNICODE + +wxWCharBuffer wxSafeConvertMB2WX(const char *s) +{ + if ( !s ) + return wxWCharBuffer(); + + wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s)); + if ( !wbuf ) + wbuf = wxConvUTF8.cMB2WX(s); + if ( !wbuf ) + wbuf = wxConvISO8859_1.cMB2WX(s); + + return wbuf; +} + +wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws) +{ + if ( !ws ) + return wxCharBuffer(); + + wxCharBuffer buf(wxConvLibc.cWX2MB(ws)); + if ( !buf ) + buf = wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL).cWX2MB(ws); + + return buf; +} + +#endif // wxUSE_UNICODE #else // !wxUSE_WCHAR_T