summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-05-20 08:46:09 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-20 08:46:09 (GMT)
commit8b3efa13709b24b5bc5d6356d8c8d94f06209fd5 (patch)
treefcc63c5afa65afefd7949f578659ab679f4d9c24 /src/corelib/tools/qchar.cpp
parent2a00c5582c23e5e7aee858725d27da4d725d03cf (diff)
downloadQt-8b3efa13709b24b5bc5d6356d8c8d94f06209fd5.zip
Qt-8b3efa13709b24b5bc5d6356d8c8d94f06209fd5.tar.gz
Qt-8b3efa13709b24b5bc5d6356d8c8d94f06209fd5.tar.bz2
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 <olivier.goffart@nokia.com>
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp10
1 files 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<const QChar *>(d), length);
+ // since the insert invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(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;
}
}