diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 94d2322fa6..49622bf196 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -1692,6 +1692,7 @@ char32_t QChar::toTitleCase(char32_t ucs4) noexcept return convertCase_helper(ucs4, QUnicodeTables::TitleCase); } +[[deprecated]] static inline uint foldCase(const ushort *ch, const ushort *start) { char32_t ucs4 = *ch; @@ -1700,6 +1701,15 @@ static inline uint foldCase(const ushort *ch, const ushort *start) return convertCase_helper(ucs4, QUnicodeTables::CaseFold); } +static inline char32_t foldCase(const char16_t *ch, const char16_t *start) +{ + char32_t ucs4 = *ch; + if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1))) + ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4); + return convertCase_helper(ucs4, QUnicodeTables::CaseFold); +} + +[[deprecated]] static inline uint foldCase(uint ch, uint &last) noexcept { char32_t ucs4 = ch; @@ -1709,11 +1719,26 @@ static inline uint foldCase(uint ch, uint &last) noexcept return convertCase_helper(ucs4, QUnicodeTables::CaseFold); } +static inline char32_t foldCase(char32_t ch, char32_t &last) noexcept +{ + char32_t ucs4 = ch; + if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last)) + ucs4 = QChar::surrogateToUcs4(last, ucs4); + last = ch; + return convertCase_helper(ucs4, QUnicodeTables::CaseFold); +} + +[[deprecated]] static inline ushort foldCase(ushort ch) noexcept { return convertCase_helper(char16_t{ch}, QUnicodeTables::CaseFold); } +static inline char16_t foldCase(char16_t ch) noexcept +{ + return convertCase_helper(ch, QUnicodeTables::CaseFold); +} + static inline QChar foldCase(QChar ch) noexcept { return QChar(foldCase(ch.unicode())); diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index bd8f536587..6b825212d3 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -879,7 +879,7 @@ static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char e = a + (be - b); while (a < e) { - int diff = foldCase(a->unicode()) - foldCase(uchar(*b)); + int diff = foldCase(a->unicode()) - foldCase(char16_t{uchar(*b)}); if ((diff)) return diff; ++a;