From 838b693b46fbe5f49a11e0d2626736d134f26aaf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 15 Jul 2021 22:26:58 +0200 Subject: [PATCH] Fix wxRegEx::GetMatch() to work in WXREGEX_CONVERT_TO_MB case Using the offset into the wide string doesn't work for non-ASCII characters, it must be converted to UTF-8 first. --- src/common/regex.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/regex.cpp b/src/common/regex.cpp index 73ac264dac..471a983fcc 100644 --- a/src/common/regex.cpp +++ b/src/common/regex.cpp @@ -906,7 +906,11 @@ wxString wxRegEx::GetMatch(const wxString& text, size_t index) const if ( !GetMatch(&start, &len, index) ) return wxEmptyString; +#ifndef WXREGEX_CONVERT_TO_MB return text.Mid(start, len); +#else + return wxString::FromUTF8(text.utf8_str().data() + start, len); +#endif } size_t wxRegEx::GetMatchCount() const