summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp81
1 files changed, 29 insertions, 52 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 5469eee14d..78fa0bccf0 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -179,8 +179,9 @@ QT_BEGIN_NAMESPACE
\value Unicode_6_2 Version 6.2
\value Unicode_6_3 Version 6.3 Since Qt 5.3
\value Unicode_7_0 Version 7.0 Since Qt 5.5
+ \value Unicode_8_0 Version 8.0 Since Qt 5.6
\value Unicode_Unassigned The value is not assigned to any character
- in version 6.3 of Unicode.
+ in version 8.0 of Unicode.
\sa unicodeVersion(), currentUnicodeVersion()
*/
@@ -401,6 +402,12 @@ QT_BEGIN_NAMESPACE
\value Script_Khudawadi
\value Script_Tirhuta
\value Script_WarangCiti
+ \value Script_Ahom
+ \value Script_AnatolianHieroglyphs
+ \value Script_Hatran
+ \value Script_Multani
+ \value Script_OldHungarian
+ \value Script_SignWriting
\omitvalue ScriptCount
@@ -1423,48 +1430,18 @@ QChar::UnicodeVersion QChar::currentUnicodeVersion() Q_DECL_NOTHROW
}
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc) Q_DECL_NOTHROW
+template <typename Traits, typename T>
+Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW
{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->lowerCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->lowerCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->lowerCaseDiff;
-}
-
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc) Q_DECL_NOTHROW
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->upperCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->upperCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->upperCaseDiff;
-}
+ const QUnicodeTables::Properties *prop = qGetProp(uc);
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc) Q_DECL_NOTHROW
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->titleCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->titleCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
+ if (Q_UNLIKELY(Traits::caseSpecial(prop))) {
+ const ushort *specialCase = specialCaseMap + Traits::caseDiff(prop);
+ // so far, there are no special cases beyond BMP (guaranteed by the qunicodetables generator)
+ return *specialCase == 1 ? specialCase[1] : uc;
}
- return uc + p->titleCaseDiff;
-}
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc) Q_DECL_NOTHROW
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->caseFoldSpecial) {
- const ushort *specialCase = specialCaseMap + p->caseFoldDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->caseFoldDiff;
+ return uc + Traits::caseDiff(prop);
}
/*!
@@ -1484,7 +1461,7 @@ uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toLowerCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::LowercaseTraits>(ucs4);
}
/*!
@@ -1504,7 +1481,7 @@ uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toUpperCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::UppercaseTraits>(ucs4);
}
/*!
@@ -1524,29 +1501,29 @@ uint QChar::toTitleCase(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toTitleCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::TitlecaseTraits>(ucs4);
}
static inline uint foldCase(const ushort *ch, const ushort *start)
{
- uint c = *ch;
- if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate())
- c = QChar::surrogateToUcs4(*(ch - 1), c);
- return toCaseFolded_helper<uint>(c);
+ uint ucs4 = *ch;
+ if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1)))
+ ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW
{
- uint c = ch;
- if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
- c = QChar::surrogateToUcs4(last, c);
+ uint ucs4 = ch;
+ if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last))
+ ucs4 = QChar::surrogateToUcs4(last, ucs4);
last = ch;
- return toCaseFolded_helper<uint>(c);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
static inline ushort foldCase(ushort ch) Q_DECL_NOTHROW
{
- return toCaseFolded_helper<ushort>(ch);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ch);
}
/*!
@@ -1565,7 +1542,7 @@ uint QChar::toCaseFolded(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toCaseFolded_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
/*!