summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-07-16 04:45:28 +0400
committerQt by Nokia <qt-info@nokia.com>2011-09-01 16:14:18 +0200
commit7a0a9bd5c4bedba771841822b53181e783292227 (patch)
tree0fd9b1c1fb130bbb999c59f29058653093d766a1 /src/corelib/tools/qchar.cpp
parent74cadacdd5f571dfbab0e8b5f626bee79761c549 (diff)
omit unassigned (and too recent) codepoints from the text Normalization process
http://www.unicode.org/reports/tr15/#Guaranteeing_Process_Stability: > handle any code points that were not defined in the earlier version > as if they were unassigned: such code points will not decompose or compose, > and their Canonical_Combining_Class value will be zero. since QChar::Unicode_Unassigned value is 0, it's less than any other QChar::UnicodeVersion value and must ba handled explicitly Change-Id: I6df025b4173d407660adae77ec5eeb98d15cb8ce Reviewed-on: http://codereview.qt.nokia.com/4084 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 736bc63b11..b68da9def4 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -1402,7 +1402,8 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
ucs4 = QChar::surrogateToUcs4(high, ucs4);
}
}
- if (QChar::unicodeVersion(ucs4) > version)
+ const QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4);
+ if (v > version || v == QChar::Unicode_Unassigned)
continue;
int length;
int tag;
@@ -1462,7 +1463,7 @@ static ushort ligatureHelper(ushort u1, ushort u2)
return 0;
}
-static void composeHelper(QString *str, int from)
+static void composeHelper(QString *str, QChar::UnicodeVersion version, int from)
{
QString &s = *str;
@@ -1482,7 +1483,14 @@ static void composeHelper(QString *str, int from)
++pos;
}
}
- int combining = QChar::combiningClass(uc);
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (p->unicodeVersion > version || p->unicodeVersion == QChar::Unicode_Unassigned) {
+ starter = -1; // to prevent starter == pos - 1
+ lastCombining = 0;
+ ++pos;
+ continue;
+ }
+ int combining = p->combiningClass;
if (starter == pos - 1 || combining > lastCombining) {
// allowed to form ligature with S
QChar ligature = ligatureHelper(s.at(starter).unicode(), uc);
@@ -1529,7 +1537,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
ushort c2 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u2);
- if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c2 = p->combiningClass;
}
if (c2 == 0) {
@@ -1540,7 +1548,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
ushort c1 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u1);
- if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c1 = p->combiningClass;
}