fix QChar::decompositionTag() returns wrong result for Hangul syllables
Change-Id: I28e7b14b6a90aa539f8a50107737a66b3484fc00 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
087cda285f
commit
95bd974163
@ -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;
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user