From 8b3efa13709b24b5bc5d6356d8c8d94f06209fd5 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 20 May 2010 10:46:09 +0200 Subject: use new QChar::requiresSurrogates() instead of hardcoded value this also fixes handling of codepoint 0x10000 ("ucs4 > 0x10000" s/>/>=/) Merge-request: 2393 Reviewed-by: Olivier Goffart --- src/corelib/tools/qchar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index ddb1516..29ecf10 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1480,9 +1480,9 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion if (!d || (canonical && tag != QChar::Canonical)) continue; - s.replace(uc - utf16, ucs4 > 0x10000 ? 2 : 1, (const QChar *)d, length); - // since the insert invalidates the pointers and we do decomposition recursive int pos = uc - utf16; + s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast(d), length); + // since the insert invalidates the pointers and we do decomposition recursive utf16 = reinterpret_cast(s.data()); uc = utf16 + pos + length; } @@ -1600,13 +1600,13 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in QChar *uc = s.data(); int p = pos; // exchange characters - if (u2 < 0x10000) { + if (!QChar::requiresSurrogates(u2)) { uc[p++] = u2; } else { uc[p++] = QChar::highSurrogate(u2); uc[p++] = QChar::lowSurrogate(u2); } - if (u1 < 0x10000) { + if (!QChar::requiresSurrogates(u1)) { uc[p++] = u1; } else { uc[p++] = QChar::highSurrogate(u1); @@ -1618,7 +1618,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in --pos; } else { ++pos; - if (u1 > 0x10000) + if (QChar::requiresSurrogates(u1)) ++pos; } } -- cgit v0.12