Avoid converting empty strings to NULL pointers in non-Unicode build
...when using utf8_str() or wxGTK_CONV as argument to const char* function parameter
This commit is contained in:
@@ -1709,7 +1709,11 @@ public:
|
|||||||
{ return FromUTF8Unchecked(utf8.c_str(), utf8.length()); }
|
{ return FromUTF8Unchecked(utf8.c_str(), utf8.length()); }
|
||||||
#endif
|
#endif
|
||||||
const wxScopedCharBuffer utf8_str() const
|
const wxScopedCharBuffer utf8_str() const
|
||||||
{ return wxMBConvUTF8().cWC2MB(wc_str()); }
|
{
|
||||||
|
if (empty())
|
||||||
|
return wxScopedCharBuffer::CreateNonOwned("", 0);
|
||||||
|
return wxMBConvUTF8().cWC2MB(wc_str());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const wxScopedCharBuffer ToUTF8() const { return utf8_str(); }
|
const wxScopedCharBuffer ToUTF8() const { return utf8_str(); }
|
||||||
|
@@ -86,6 +86,9 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
|||||||
WXDLLIMPEXP_CORE wxCharBuffer
|
WXDLLIMPEXP_CORE wxCharBuffer
|
||||||
wxConvertToGTK(const wxString& s, wxFontEncoding enc)
|
wxConvertToGTK(const wxString& s, wxFontEncoding enc)
|
||||||
{
|
{
|
||||||
|
if (s.empty())
|
||||||
|
return wxCharBuffer("");
|
||||||
|
|
||||||
wxWCharBuffer wbuf;
|
wxWCharBuffer wbuf;
|
||||||
if ( enc == wxFONTENCODING_SYSTEM || enc == wxFONTENCODING_DEFAULT )
|
if ( enc == wxFONTENCODING_SYSTEM || enc == wxFONTENCODING_DEFAULT )
|
||||||
{
|
{
|
||||||
@@ -96,7 +99,7 @@ wxConvertToGTK(const wxString& s, wxFontEncoding enc)
|
|||||||
wbuf = wxCSConv(enc).cMB2WC(s.c_str());
|
wbuf = wxCSConv(enc).cMB2WC(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !wbuf && !s.empty() )
|
if (wbuf.length() == 0)
|
||||||
{
|
{
|
||||||
// conversion failed, but we still want to show something to the user
|
// conversion failed, but we still want to show something to the user
|
||||||
// even if it's going to be wrong it is better than nothing
|
// even if it's going to be wrong it is better than nothing
|
||||||
|
Reference in New Issue
Block a user