File tree Expand file tree Collapse file tree 2 files changed +5
-34
lines changed
Expand file tree Collapse file tree 2 files changed +5
-34
lines changed Original file line number Diff line number Diff line change @@ -2035,41 +2035,12 @@ String String::reversed() const
20352035 if (numChars <= 0 )
20362036 return *this ;
20372037
2038- auto isCombiningMark = [] (yup_wchar c)
2039- {
2040- // Combining Diacritical Marks
2041- if (c >= 0x0300 && c <= 0x036F )
2042- return true ;
2043- // Combining Diacritical Marks Extended
2044- if (c >= 0x1AB0 && c <= 0x1AFF )
2045- return true ;
2046- // Combining Diacritical Marks Supplement
2047- if (c >= 0x1DC0 && c <= 0x1DFF )
2048- return true ;
2049- // Combining Half Marks
2050- if (c >= 0xFE20 && c <= 0xFE2F )
2051- return true ;
2052- // Combining Diacritical Marks for Symbols
2053- if (c >= 0x20D0 && c <= 0x20FF )
2054- return true ;
2055- return false ;
2056- };
2057-
2058- std::vector<String> clusters;
2038+ std::vector<yup_wchar> clusters;
20592039 clusters.reserve (numChars);
20602040
2061- for (int i = 0 ; i < numChars; ++i)
2062- {
2063- String cluster = substring (i, i + 1 );
2064-
2065- while (i + 1 < numChars && isCombiningMark ((*this )[i + 1 ]))
2066- {
2067- ++i;
2068- cluster += substring (i, i + 1 );
2069- }
2070-
2071- clusters.emplace_back (std::move (cluster));
2072- }
2041+ CharPointerType p{ text };
2042+ while (! p.isEmpty ())
2043+ clusters.push_back (p.getAndAdvance ());
20732044
20742045 String result;
20752046 result.preallocateBytes (numChars);
Original file line number Diff line number Diff line change @@ -764,7 +764,7 @@ TEST_F (StringTests, StringReversing)
764764 EXPECT_EQ (String ().reversed (), String ());
765765 EXPECT_EQ (String (" 12345" ).reversed (), String (" 54321" ));
766766
767- #if ! YUP_WINDOWS
767+ #if 1 // ! YUP_WINDOWS
768768 // Test with Unicode characters - this is the critical test for UTF-8 handling
769769 String unicode_str (L" café" );
770770 String reversed_unicode = unicode_str.reversed ();
You can’t perform that action at this time.
0 commit comments