diff --git a/include/wx/string.h b/include/wx/string.h index a5a3b3108a..6e579ed616 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1709,7 +1709,11 @@ public: { return FromUTF8Unchecked(utf8.c_str(), utf8.length()); } #endif const wxScopedCharBuffer utf8_str() const - { return wxMBConvUTF8().cWC2MB(wc_str()); } + { + if (empty()) + return wxScopedCharBuffer::CreateNonOwned("", 0); + return wxMBConvUTF8().cWC2MB(wc_str()); + } #endif const wxScopedCharBuffer ToUTF8() const { return utf8_str(); } diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 137fb2cf16..4a7afc9edc 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -86,6 +86,9 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) WXDLLIMPEXP_CORE wxCharBuffer wxConvertToGTK(const wxString& s, wxFontEncoding enc) { + if (s.empty()) + return wxCharBuffer(""); + wxWCharBuffer wbuf; if ( enc == wxFONTENCODING_SYSTEM || enc == wxFONTENCODING_DEFAULT ) { @@ -96,7 +99,7 @@ wxConvertToGTK(const wxString& s, wxFontEncoding enc) 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 // even if it's going to be wrong it is better than nothing