From: Konstantin Ritt Date: Mon, 16 Apr 2012 09:52:52 +0000 (+0300) Subject: fix QChar::decompositionTag() returns wrong result for Hangul syllables X-Git-Tag: 071012110112~1608 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95bd974163d9103634a5ce4cbfc9bc3c4827dee1;p=profile%2Fivi%2Fqtbase.git fix QChar::decompositionTag() returns wrong result for Hangul syllables Change-Id: I28e7b14b6a90aa539f8a50107737a66b3484fc00 Reviewed-by: Lars Knoll --- diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 80233b4..e3d6c60 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -981,6 +981,8 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4) { if (ucs4 > UNICODE_LAST_CODEPOINT) return QChar::NoDecomposition; + if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) + return QChar::Canonical; const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4); if (index == 0xffff) return QChar::NoDecomposition; diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index 56613a9..1a56807 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -608,6 +608,14 @@ void tst_QChar::mirroredChar() void tst_QChar::decomposition() { + // Hangul syllables + for (uint ucs = 0xac00; ucs <= 0xd7af; ++ucs) { + QChar::Decomposition expected = QChar::unicodeVersion(ucs) > QChar::Unicode_Unassigned ? QChar::Canonical : QChar::NoDecomposition; + QString desc = QString::fromLatin1("ucs = 0x%1, tag = %2, expected = %3") + .arg(QString::number(ucs, 16)).arg(QChar::decompositionTag(ucs)).arg(expected); + QVERIFY2(QChar::decompositionTag(ucs) == expected, desc.toLatin1()); + } + QVERIFY(QChar((ushort)0xa0).decompositionTag() == QChar::NoBreak); QVERIFY(QChar((ushort)0xa8).decompositionTag() == QChar::Compat); QVERIFY(QChar((ushort)0x41).decompositionTag() == QChar::NoDecomposition); @@ -805,6 +813,25 @@ void tst_QChar::normalization_manual() QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed); QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed); } + { // hangul + QString composed; + composed += QChar(0xc154); + composed += QChar(0x11f0); + QString decomposed; + decomposed += QChar(0x1109); + decomposed += QChar(0x1167); + decomposed += QChar(0x11f0); + + QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed); + QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed); + QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed); + QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed); + + QVERIFY(decomposed.normalized(QString::NormalizationForm_D) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_C) == composed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KD) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KC) == composed); + } } void tst_QChar::normalizationCorrections()