diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 80233b430a..e3d6c60b0f 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 56613a90c2..1a568073cf 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()