From 140d6fea88121a252e1e690b2e5ede43474af02f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 6 Dec 2017 03:38:39 +0100 Subject: [PATCH] Add wxString ctor from wxScopedCharBuffer and wxMBConv This is more convenient and less error prone than using the existing ctor taking char pointer and length as the buffer contains both. Also add the corresponding assign() overload for consistency. See #16490. --- include/wx/string.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/wx/string.h b/include/wx/string.h index b80998cc44..a4e682b8ff 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -1162,6 +1162,9 @@ public: wxString(const wxScopedWCharBuffer& buf) { assign(buf.data(), buf.length()); } + wxString(const wxScopedCharBuffer& buf, const wxMBConv& conv) + { assign(buf, conv); } + // NB: this version uses m_impl.c_str() to force making a copy of the // string, so that "wxString(str.c_str())" idiom for passing strings // between threads works @@ -2539,6 +2542,13 @@ public: { return assign(str.AsString()); } wxString& assign(const wxScopedCharBuffer& str) { return assign(str.data(), str.length()); } + wxString& assign(const wxScopedCharBuffer& buf, const wxMBConv& conv) + { + SubstrBufFromMB str(ImplStr(buf.data(), buf.length(), conv)); + m_impl.assign(str.data, str.len); + + return *this; + } wxString& assign(const wxScopedWCharBuffer& str) { return assign(str.data(), str.length()); } wxString& assign(const wxCStrData& str, size_t len)