X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c714a5d0718a51c57338986e9736f58ae355042..8e34db1d94748cc22be9531173a3223faecc7099:/include/wx/strconv.h diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 947efad799..4e4afff9dc 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -385,6 +385,9 @@ public: void Clear(); + // return true if the conversion could be initilized successfully + bool IsOk() const; + private: // common part of all ctors void Init(); @@ -518,10 +521,25 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent; #if wxUSE_UNICODE #define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s) #define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s) + + // these functions should be used when the conversions really, really have + // to succeed (usually because we pass their results to a standard C + // function which would crash if we passed NULL to it), so these functions + // always return a valid pointer if their argument is non-NULL + + // this function safety is achieved by trying wxConvLibc first, wxConvUTF8 + // next if it fails and, finally, wxConvISO8859_1 which always succeeds + extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s); + + // this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL) + // if it fails + extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws); #else // ANSI // no conversions to do #define wxConvertWX2MB(s) (s) #define wxConvertMB2WX(s) (s) + #define wxSafeConvertMB2WX(s) (s) + #define wxSafeConvertWX2MB(s) (s) #endif // Unicode/ANSI #endif // _WX_STRCONV_H_