Reimplement wxSafeConvertXXX() functions using wxWhateverWorksConv
These functions were almost but not quite identical to it: wxSafeConvertMB2WX() tried the current locale encoding before UTF-8 while wxConvWhateverWorks tries UTF-8 first and then the current locale encoding. The latter behaviour is more correct as valid UTF-8 could be misinterpreted as some legacy multibyte encoding otherwise, so get rid of this difference and just forward these functions to wxConvWhateverWorks.
This commit is contained in:
@@ -687,12 +687,15 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI;
|
|||||||
// function which would crash if we passed NULL to it), so these functions
|
// function which would crash if we passed NULL to it), so these functions
|
||||||
// always return a valid pointer if their argument is non-NULL
|
// always return a valid pointer if their argument is non-NULL
|
||||||
|
|
||||||
// this function safety is achieved by trying wxConvLibc first, wxConvUTF8
|
inline wxWCharBuffer wxSafeConvertMB2WX(const char *s)
|
||||||
// next if it fails and, finally, wxConvISO8859_1 which always succeeds
|
{
|
||||||
extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s);
|
return wxConvWhateverWorks.cMB2WC(s);
|
||||||
|
}
|
||||||
|
|
||||||
// this function uses wxConvLibc and wxConvUTF8 if it fails
|
inline wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws)
|
||||||
extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws);
|
{
|
||||||
|
return wxConvWhateverWorks.cWC2MB(ws);
|
||||||
|
}
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
// no conversions to do
|
// no conversions to do
|
||||||
#define wxConvertWX2MB(s) (s)
|
#define wxConvertWX2MB(s) (s)
|
||||||
|
@@ -3320,36 +3320,6 @@ wxWhateverWorksConv::FromWChar(char *dst, size_t dstLen,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 = wxConvUTF8.cWX2MB(ws);
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_UNICODE
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// globals
|
// globals
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user