diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 8c2576999e..79e6e16af8 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1618,44 +1618,25 @@ double ElapsedTime::Duration(bool reset) { #if wxUSE_UNICODE -#include "UniConversion.h" - -// Convert using Scintilla's functions instead of wx's, Scintilla's are more -// forgiving and won't assert... +// For historical reasons, we use Scintilla-specific conversion functions, we +// should probably just call FromUTF8()/utf8_str() directly instead now. wxString stc2wx(const char* str, size_t len) { - if (!len) - return wxEmptyString; - - size_t wclen = UTF16Length(str, len); - wxWCharBuffer buffer(wclen+1); - - size_t actualLen = UTF16FromUTF8(str, len, buffer.data(), wclen+1); - return wxString(buffer.data(), actualLen); + return wxString::FromUTF8(str, len); } wxString stc2wx(const char* str) { - return stc2wx(str, strlen(str)); + return wxString::FromUTF8(str); } wxWX2MBbuf wx2stc(const wxString& str) { - const wchar_t* wcstr = str.c_str(); - size_t wclen = str.length(); - size_t len = UTF8Length(wcstr, wclen); - - // The buffer object adds extra byte for the terminating NUL and we must - // pass the total length, including this NUL, to UTF8FromUTF16() to ensure - // that it NULL-terminates the string. - wxCharBuffer buffer(len); - UTF8FromUTF16(wcstr, wclen, buffer.data(), len + 1); - - return buffer; + return str.utf8_str(); } #endif