OSDN Git Service

Fix issue #914: Unicode SMP chars misrendered after performing a find
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Fri, 13 Aug 2021 11:43:03 +0000 (20:43 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Fri, 13 Aug 2021 11:43:03 +0000 (20:43 +0900)
Externals/crystaledit/editlib/utils/cregexp_poco.cpp

index 8ec68a9..2752f30 100644 (file)
@@ -101,8 +101,11 @@ int RxExec(RxNode *Regexp, LPCTSTR Data, size_t Len, LPCTSTR Start, RxMatchRes *
                for (i = 0; i < result; i++)
                {
 #ifdef UNICODE
-                       Match->Open[i] = ucr::stringlen_of_utf8(compString.c_str(), ovector[i].offset);
-                       Match->Close[i] = ucr::stringlen_of_utf8(compString.c_str(), ovector[i].offset + ovector[i].length);
+                       std::wstring utf16str;
+                       UnicodeConverter::toUTF16(std::string(compString.c_str(), ovector[i].offset), utf16str);
+                       Match->Open[i] = utf16str.length();
+                       UnicodeConverter::toUTF16(std::string(compString.c_str() + ovector[i].offset, ovector[i].length), utf16str);
+                       Match->Close[i] = Match->Open[i] + utf16str.length();
 #else
                        Match->Open[i] = ovector[i].offset;
                        Match->Close[i] = ovector[i].offset + ovector[i].length;