Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qchar.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4// Don't define it while compiling this module, or USERS of Qt will
5// not be able to link.
6#ifdef QT_NO_CAST_FROM_ASCII
7# undef QT_NO_CAST_FROM_ASCII
8#endif
9#ifdef QT_NO_CAST_TO_ASCII
10# undef QT_NO_CAST_TO_ASCII
11#endif
12#include "qchar.h"
13
14#include "qdatastream.h"
15
16#include "qunicodetables_p.h"
17#include "qunicodetables.cpp"
18
19#include <algorithm>
20
22
23#define FLAG(x) (1 << (x))
24
759bool QChar::isPrint(char32_t ucs4) noexcept
760{
761 if (ucs4 > LastValidCodePoint)
762 return false;
763 const int test = FLAG(Other_Control) |
764 FLAG(Other_Format) |
765 FLAG(Other_Surrogate) |
766 FLAG(Other_PrivateUse) |
767 FLAG(Other_NotAssigned);
768 return !(FLAG(qGetProp(ucs4)->category) & test);
769}
770
794bool QT_FASTCALL QChar::isSpace_helper(char32_t ucs4) noexcept
795{
796 if (ucs4 > LastValidCodePoint)
797 return false;
798 const int test = FLAG(Separator_Space) |
799 FLAG(Separator_Line) |
800 FLAG(Separator_Paragraph);
801 return FLAG(qGetProp(ucs4)->category) & test;
802}
803
822bool QChar::isMark(char32_t ucs4) noexcept
823{
824 if (ucs4 > LastValidCodePoint)
825 return false;
826 const int test = FLAG(Mark_NonSpacing) |
827 FLAG(Mark_SpacingCombining) |
828 FLAG(Mark_Enclosing);
829 return FLAG(qGetProp(ucs4)->category) & test;
830}
831
848bool QChar::isPunct(char32_t ucs4) noexcept
849{
850 if (ucs4 > LastValidCodePoint)
851 return false;
852 const int test = FLAG(Punctuation_Connector) |
853 FLAG(Punctuation_Dash) |
854 FLAG(Punctuation_Open) |
855 FLAG(Punctuation_Close) |
856 FLAG(Punctuation_InitialQuote) |
857 FLAG(Punctuation_FinalQuote) |
858 FLAG(Punctuation_Other);
859 return FLAG(qGetProp(ucs4)->category) & test;
860}
861
878bool QChar::isSymbol(char32_t ucs4) noexcept
879{
880 if (ucs4 > LastValidCodePoint)
881 return false;
882 const int test = FLAG(Symbol_Math) |
883 FLAG(Symbol_Currency) |
884 FLAG(Symbol_Modifier) |
885 FLAG(Symbol_Other);
886 return FLAG(qGetProp(ucs4)->category) & test;
887}
888
910bool QT_FASTCALL QChar::isLetter_helper(char32_t ucs4) noexcept
911{
912 if (ucs4 > LastValidCodePoint)
913 return false;
914 const int test = FLAG(Letter_Uppercase) |
915 FLAG(Letter_Lowercase) |
916 FLAG(Letter_Titlecase) |
917 FLAG(Letter_Modifier) |
918 FLAG(Letter_Other);
919 return FLAG(qGetProp(ucs4)->category) & test;
920}
921
947bool QT_FASTCALL QChar::isNumber_helper(char32_t ucs4) noexcept
948{
949 if (ucs4 > LastValidCodePoint)
950 return false;
951 const int test = FLAG(Number_DecimalDigit) |
952 FLAG(Number_Letter) |
953 FLAG(Number_Other);
954 return FLAG(qGetProp(ucs4)->category) & test;
955}
956
978bool QT_FASTCALL QChar::isLetterOrNumber_helper(char32_t ucs4) noexcept
979{
980 if (ucs4 > LastValidCodePoint)
981 return false;
982 const int test = FLAG(Letter_Uppercase) |
983 FLAG(Letter_Lowercase) |
984 FLAG(Letter_Titlecase) |
985 FLAG(Letter_Modifier) |
986 FLAG(Letter_Other) |
987 FLAG(Number_DecimalDigit) |
988 FLAG(Number_Letter) |
989 FLAG(Number_Other);
990 return FLAG(qGetProp(ucs4)->category) & test;
991}
992
1163int QChar::digitValue(char32_t ucs4) noexcept
1164{
1165 if (ucs4 > LastValidCodePoint)
1166 return -1;
1167 return qGetProp(ucs4)->digitValue;
1168}
1169
1182QChar::Category QChar::category(char32_t ucs4) noexcept
1183{
1184 if (ucs4 > LastValidCodePoint)
1186 return (QChar::Category) qGetProp(ucs4)->category;
1187}
1188
1201QChar::Direction QChar::direction(char32_t ucs4) noexcept
1202{
1203 if (ucs4 > LastValidCodePoint)
1204 return QChar::DirL;
1205 return (QChar::Direction) qGetProp(ucs4)->direction;
1206}
1207
1227{
1228 if (ucs4 > LastValidCodePoint)
1229 return QChar::Joining_None;
1230 return QChar::JoiningType(qGetProp(ucs4)->joining);
1231}
1232
1257bool QChar::hasMirrored(char32_t ucs4) noexcept
1258{
1259 if (ucs4 > LastValidCodePoint)
1260 return false;
1261 return qGetProp(ucs4)->mirrorDiff != 0;
1262}
1263
1347char32_t QChar::mirroredChar(char32_t ucs4) noexcept
1348{
1349 if (ucs4 > LastValidCodePoint)
1350 return ucs4;
1351 return ucs4 + qGetProp(ucs4)->mirrorDiff;
1352}
1353
1354// Constants for Hangul (de)composition, see UAX #15:
1355static constexpr char32_t Hangul_SBase = 0xac00;
1356static constexpr char32_t Hangul_LBase = 0x1100;
1357static constexpr char32_t Hangul_VBase = 0x1161;
1358static constexpr char32_t Hangul_TBase = 0x11a7;
1359static constexpr quint32 Hangul_LCount = 19;
1360static constexpr quint32 Hangul_VCount = 21;
1361static constexpr quint32 Hangul_TCount = 28;
1364
1365// buffer has to have a length of 3. It's needed for Hangul decomposition
1368{
1369 if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) {
1370 // compute Hangul syllable decomposition as per UAX #15
1371 const char32_t SIndex = ucs4 - Hangul_SBase;
1372 buffer[0] = QChar(Hangul_LBase + SIndex / Hangul_NCount); // L
1373 buffer[1] = QChar(Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount); // V
1374 buffer[2] = QChar(Hangul_TBase + SIndex % Hangul_TCount); // T
1375 *length = buffer[2].unicode() == Hangul_TBase ? 2 : 3;
1377 return buffer;
1378 }
1379
1380 const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1381 if (index == 0xffff) {
1382 *length = 0;
1384 return nullptr;
1385 }
1386
1387 const unsigned short *decomposition = uc_decomposition_map+index;
1388 *tag = QChar::Decomposition((*decomposition) & 0xff);
1389 *length = (*decomposition) >> 8;
1390 return reinterpret_cast<const QChar *>(decomposition + 1);
1391}
1392
1398{
1399 return QChar::decomposition(ucs);
1400}
1401
1410{
1411 QChar buffer[3];
1414 const QChar *d = decompositionHelper(ucs4, &length, &tag, buffer);
1415 return QString(d, length);
1416}
1417
1433{
1434 if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
1435 return QChar::Canonical;
1436 const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1437 if (index == 0xffff)
1440}
1441
1460unsigned char QChar::combiningClass(char32_t ucs4) noexcept
1461{
1462 if (ucs4 > LastValidCodePoint)
1463 return 0;
1464 return (unsigned char) qGetProp(ucs4)->combiningClass;
1465}
1466
1483QChar::Script QChar::script(char32_t ucs4) noexcept
1484{
1485 if (ucs4 > LastValidCodePoint)
1486 return QChar::Script_Unknown;
1487 return (QChar::Script) qGetProp(ucs4)->script;
1488}
1489
1504{
1505 if (ucs4 > LastValidCodePoint)
1508}
1509
1514{
1515 return UNICODE_DATA_VERSION;
1516}
1517
1518static auto fullConvertCase(char32_t uc, QUnicodeTables::Case which) noexcept
1519{
1520 struct R {
1521 char16_t chars[MaxSpecialCaseLength + 1];
1522 qint8 sz;
1523
1524 // iterable
1525 auto begin() const { return chars; }
1526 auto end() const { return chars + sz; }
1527 // QStringView-compatible
1528 auto data() const { return chars; }
1529 auto size() const { return sz; }
1530 } result;
1532
1533 auto pp = result.chars;
1534
1535 const auto fold = qGetProp(uc)->cases[which];
1536 const auto caseDiff = fold.diff;
1537
1538 if (Q_UNLIKELY(fold.special)) {
1539 const auto *specialCase = specialCaseMap + caseDiff;
1540 auto length = *specialCase++;
1541 while (length--)
1542 *pp++ = *specialCase++;
1543 } else {
1544 // so far, case conversion never changes planes (guaranteed by the qunicodetables generator)
1545 for (char16_t c : QChar::fromUcs4(uc + caseDiff))
1546 *pp++ = c;
1547 }
1548 result.sz = pp - result.chars;
1549 return result;
1550}
1551
1552template <typename T>
1554{
1555 const auto fold = qGetProp(uc)->cases[which];
1556
1557 if (Q_UNLIKELY(fold.special)) {
1558 const ushort *specialCase = specialCaseMap + fold.diff;
1559 // so far, there are no special cases beyond BMP (guaranteed by the qunicodetables generator)
1560 return *specialCase == 1 ? specialCase[1] : uc;
1561 }
1562
1563 return uc + fold.diff;
1564}
1565
1581char32_t QChar::toLower(char32_t ucs4) noexcept
1582{
1583 if (ucs4 > LastValidCodePoint)
1584 return ucs4;
1586}
1587
1603char32_t QChar::toUpper(char32_t ucs4) noexcept
1604{
1605 if (ucs4 > LastValidCodePoint)
1606 return ucs4;
1608}
1609
1625char32_t QChar::toTitleCase(char32_t ucs4) noexcept
1626{
1627 if (ucs4 > LastValidCodePoint)
1628 return ucs4;
1630}
1631
1632static inline char32_t foldCase(const char16_t *ch, const char16_t *start)
1633{
1634 char32_t ucs4 = *ch;
1635 if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1)))
1636 ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4);
1638}
1639
1640static inline char32_t foldCase(char32_t ch, char32_t &last) noexcept
1641{
1642 char32_t ucs4 = ch;
1644 ucs4 = QChar::surrogateToUcs4(last, ucs4);
1645 last = ch;
1647}
1648
1649static inline char16_t foldCase(char16_t ch) noexcept
1650{
1652}
1653
1654static inline QChar foldCase(QChar ch) noexcept
1655{
1656 return QChar(foldCase(ch.unicode()));
1657}
1658
1673char32_t QChar::toCaseFolded(char32_t ucs4) noexcept
1674{
1675 if (ucs4 > LastValidCodePoint)
1676 return ucs4;
1678}
1679
1703#ifndef QT_NO_DATASTREAM
1712{
1713 out << quint16(chr.unicode());
1714 return out;
1715}
1716
1725{
1726 quint16 u;
1727 in >> u;
1728 chr.unicode() = char16_t(u);
1729 return in;
1730}
1731#endif // QT_NO_DATASTREAM
1732
1745/*****************************************************************************
1746 Documentation of QChar related functions
1747 *****************************************************************************/
1748
1809// ---------------------------------------------------------------------------
1810
1811
1812static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, qsizetype from)
1813{
1816 QChar buffer[3];
1817
1818 QString &s = *str;
1819
1820 const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data());
1821 const unsigned short *uc = utf16 + s.size();
1822 while (uc != utf16 + from) {
1823 char32_t ucs4 = *(--uc);
1824 if (QChar(ucs4).isLowSurrogate() && uc != utf16) {
1825 ushort high = *(uc - 1);
1826 if (QChar(high).isHighSurrogate()) {
1827 --uc;
1828 ucs4 = QChar::surrogateToUcs4(high, ucs4);
1829 }
1830 }
1831
1832 if (QChar::unicodeVersion(ucs4) > version)
1833 continue;
1834
1835 const QChar *d = decompositionHelper(ucs4, &length, &tag, buffer);
1836 if (!d || (canonical && tag != QChar::Canonical))
1837 continue;
1838
1839 qsizetype pos = uc - utf16;
1840 s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, d, length);
1841 // since the replace invalidates the pointers and we do decomposition recursive
1842 utf16 = reinterpret_cast<unsigned short *>(s.data());
1843 uc = utf16 + pos + length;
1844 }
1845}
1846
1847
1848struct UCS2Pair {
1851};
1852
1853inline bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2)
1854{ return ligature1.u1 < ligature2.u1; }
1855inline bool operator<(ushort u1, const UCS2Pair &ligature)
1856{ return u1 < ligature.u1; }
1857inline bool operator<(const UCS2Pair &ligature, ushort u1)
1858{ return ligature.u1 < u1; }
1859
1863};
1864
1865inline bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2)
1866{ return QChar::surrogateToUcs4(ligature1.p1.u1, ligature1.p1.u2) < QChar::surrogateToUcs4(ligature2.p1.u1, ligature2.p1.u2); }
1867inline bool operator<(char32_t u1, const UCS2SurrogatePair &ligature)
1868{ return u1 < QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2); }
1869inline bool operator<(const UCS2SurrogatePair &ligature, char32_t u1)
1870{ return QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2) < u1; }
1871
1872static char32_t inline ligatureHelper(char32_t u1, char32_t u2)
1873{
1875 // compute Hangul syllable composition as per UAX #15
1876 // hangul L-V pair
1877 const char32_t LIndex = u1 - Hangul_LBase;
1878 if (LIndex < Hangul_LCount) {
1879 const char32_t VIndex = u2 - Hangul_VBase;
1880 if (VIndex < Hangul_VCount)
1881 return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
1882 }
1883 // hangul LV-T pair
1884 const char32_t SIndex = u1 - Hangul_SBase;
1885 if (SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
1886 const char32_t TIndex = u2 - Hangul_TBase;
1887 if (TIndex < Hangul_TCount && TIndex)
1888 return u1 + TIndex;
1889 }
1890 }
1891
1892 const unsigned short index = GET_LIGATURE_INDEX(u2);
1893 if (index == 0xffff)
1894 return 0;
1895 const unsigned short *ligatures = uc_ligature_map+index;
1896 ushort length = *ligatures++;
1898 const UCS2SurrogatePair *data = reinterpret_cast<const UCS2SurrogatePair *>(ligatures);
1899 const UCS2SurrogatePair *r = std::lower_bound(data, data + length, u1);
1900 if (r != data + length && QChar::surrogateToUcs4(r->p1.u1, r->p1.u2) == u1)
1901 return QChar::surrogateToUcs4(r->p2.u1, r->p2.u2);
1902 } else {
1903 const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures);
1904 const UCS2Pair *r = std::lower_bound(data, data + length, ushort(u1));
1905 if (r != data + length && r->u1 == ushort(u1))
1906 return r->u2;
1907 }
1908
1909 return 0;
1910}
1911
1913{
1914 QString &s = *str;
1915
1916 if (from < 0 || s.size() - from < 2)
1917 return;
1918
1919 char32_t stcode = 0; // starter code point
1920 qsizetype starter = -1; // starter position
1921 qsizetype next = -1; // to prevent i == next
1922 int lastCombining = 255; // to prevent combining > lastCombining
1923
1924 qsizetype pos = from;
1925 while (pos < s.size()) {
1926 qsizetype i = pos;
1927 char32_t uc = s.at(pos).unicode();
1928 if (QChar(uc).isHighSurrogate() && pos < s.size()-1) {
1929 ushort low = s.at(pos+1).unicode();
1930 if (QChar(low).isLowSurrogate()) {
1931 uc = QChar::surrogateToUcs4(uc, low);
1932 ++pos;
1933 }
1934 }
1935
1937 if (p->unicodeVersion > version) {
1938 starter = -1;
1939 next = -1; // to prevent i == next
1940 lastCombining = 255; // to prevent combining > lastCombining
1941 ++pos;
1942 continue;
1943 }
1944
1945 int combining = p->combiningClass;
1946 if ((i == next || combining > lastCombining) && starter >= from) {
1947 // allowed to form ligature with S
1948 char32_t ligature = ligatureHelper(stcode, uc);
1949 if (ligature) {
1950 stcode = ligature;
1951 QChar *d = s.data();
1952 // ligatureHelper() never changes planes
1953 qsizetype j = 0;
1954 for (QChar ch : QChar::fromUcs4(ligature))
1955 d[starter + j++] = ch;
1956 s.remove(i, j);
1957 continue;
1958 }
1959 }
1960 if (combining == 0) {
1961 starter = i;
1962 stcode = uc;
1963 next = pos + 1;
1964 }
1965 lastCombining = combining;
1966
1967 ++pos;
1968 }
1969}
1970
1971
1973{
1974 QString &s = *str;
1975 const qsizetype l = s.size()-1;
1976
1977 char32_t u1, u2;
1978 char16_t c1, c2;
1979
1980 qsizetype pos = from;
1981 while (pos < l) {
1982 qsizetype p2 = pos+1;
1983 u1 = s.at(pos).unicode();
1985 const char16_t low = s.at(p2).unicode();
1986 if (QChar::isLowSurrogate(low)) {
1988 if (p2 >= l)
1989 break;
1990 ++p2;
1991 }
1992 }
1993 c1 = 0;
1994
1995 advance:
1996 u2 = s.at(p2).unicode();
1997 if (QChar::isHighSurrogate(u2) && p2 < l) {
1998 const char16_t low = s.at(p2+1).unicode();
1999 if (QChar::isLowSurrogate(low)) {
2001 ++p2;
2002 }
2003 }
2004
2005 c2 = 0;
2006 {
2008 if (p->unicodeVersion <= version)
2009 c2 = p->combiningClass;
2010 }
2011 if (c2 == 0) {
2012 pos = p2+1;
2013 continue;
2014 }
2015
2016 if (c1 == 0) {
2018 if (p->unicodeVersion <= version)
2019 c1 = p->combiningClass;
2020 }
2021
2022 if (c1 > c2) {
2023 QChar *uc = s.data();
2024 qsizetype p = pos;
2025 // exchange characters
2026 for (QChar ch : QChar::fromUcs4(u2))
2027 uc[p++] = ch;
2028 for (QChar ch : QChar::fromUcs4(u1))
2029 uc[p++] = ch;
2030 if (pos > 0)
2031 --pos;
2032 if (pos > 0 && s.at(pos).isLowSurrogate())
2033 --pos;
2034 } else {
2035 ++pos;
2037 ++pos;
2038
2039 u1 = u2;
2040 c1 = c2; // != 0
2041 p2 = pos + 1;
2043 ++p2;
2044 if (p2 > l)
2045 break;
2046
2047 goto advance;
2048 }
2049 }
2050}
2051
2052// returns true if the text is in a desired Normalization Form already; false otherwise.
2053// sets lastStable to the position of the last stable code point
2055{
2056 static_assert(QString::NormalizationForm_D == 0);
2057 static_assert(QString::NormalizationForm_C == 1);
2058 static_assert(QString::NormalizationForm_KD == 2);
2059 static_assert(QString::NormalizationForm_KC == 3);
2060
2061 enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
2062
2063 const auto *string = reinterpret_cast<const char16_t *>(str->constData());
2064 qsizetype length = str->size();
2065
2066 // this avoids one out of bounds check in the loop
2067 while (length > from && QChar::isHighSurrogate(string[length - 1]))
2068 --length;
2069
2070 uchar lastCombining = 0;
2071 for (qsizetype i = from; i < length; ++i) {
2072 qsizetype pos = i;
2073 char32_t uc = string[i];
2074 if (uc < 0x80) {
2075 // ASCII characters are stable code points
2076 lastCombining = 0;
2077 *lastStable = pos;
2078 continue;
2079 }
2080
2081 if (QChar::isHighSurrogate(uc)) {
2082 ushort low = string[i + 1];
2083 if (!QChar::isLowSurrogate(low)) {
2084 // treat surrogate like stable code point
2085 lastCombining = 0;
2086 *lastStable = pos;
2087 continue;
2088 }
2089 ++i;
2090 uc = QChar::surrogateToUcs4(uc, low);
2091 }
2092
2094
2095 if (p->combiningClass < lastCombining && p->combiningClass > 0)
2096 return false;
2097
2098 const uchar check = (p->nfQuickCheck >> (mode << 1)) & 0x03;
2099 if (check != NFQC_YES)
2100 return false; // ### can we quick check NFQC_MAYBE ?
2101
2102 lastCombining = p->combiningClass;
2103 if (lastCombining == 0)
2104 *lastStable = pos;
2105 }
2106
2107 if (length != str->size()) // low surrogate parts at the end of text
2108 *lastStable = str->size() - 1;
2109
2110 return true;
2111}
2112
\inmodule QtCore
Definition qchar.h:48
static constexpr char32_t surrogateToUcs4(char16_t high, char16_t low) noexcept
Converts a UTF16 surrogate pair with the given high and low values to it's UCS-4-encoded code point.
Definition qchar.h:508
@ LastValidCodePoint
Definition qchar.h:66
static constexpr bool requiresSurrogates(char32_t ucs4) noexcept
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
Definition qchar.h:504
Decomposition
This enum type defines the Unicode decomposition attributes.
Definition qchar.h:352
@ NoDecomposition
Definition qchar.h:353
@ Canonical
Definition qchar.h:354
Script script() const noexcept
Definition qchar.h:453
QChar toLower() const noexcept
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition qchar.h:448
int digitValue() const noexcept
Returns the numeric value of the digit, or -1 if the character is not a digit.
Definition qchar.h:447
Direction direction() const noexcept
Returns the character's direction.
Definition qchar.h:437
bool hasMirrored() const noexcept
Returns true if the character should be reversed if the text direction is reversed; otherwise returns...
Definition qchar.h:442
static constexpr auto fromUcs4(char32_t c) noexcept
Direction
This enum type defines the Unicode direction attributes.
Definition qchar.h:345
@ DirL
Definition qchar.h:346
QChar mirroredChar() const noexcept
Returns the mirrored character if this character is a mirrored character; otherwise returns the chara...
Definition qchar.h:441
UnicodeVersion
Specifies which version of the \l{Unicode standard} introduced a certain character.
Definition qchar.h:407
@ Unicode_Unassigned
Definition qchar.h:408
Category
This enum maps the Unicode character categories.
Definition qchar.h:104
@ Other_NotAssigned
Definition qchar.h:121
constexpr bool isLowSurrogate() const noexcept
Returns true if the QChar is the low part of a UTF16 surrogate (for example if its code point is in r...
Definition qchar.h:480
QDataStream & operator<<(QDataStream &out, QChar chr)
Writes the char chr to the stream out.
Definition qchar.cpp:1711
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
Definition qchar.h:458
QChar toCaseFolded() const noexcept
Returns the case folded equivalent of the character.
Definition qchar.h:451
bool isPrint() const noexcept
Returns true if the character is a printable character; otherwise returns false.
Definition qchar.h:465
QString decomposition() const
Decomposes a character into it's constituent parts.
Definition qchar.cpp:1397
JoiningType
since 5.3
Definition qchar.h:373
@ Joining_None
Definition qchar.h:374
Category category() const noexcept
Returns the character's category.
Definition qchar.h:436
Script
Definition qchar.h:144
@ Script_Unknown
Definition qchar.h:145
unsigned char combiningClass() const noexcept
Returns the combining class for the character as defined in the Unicode standard.
Definition qchar.h:439
Decomposition decompositionTag() const noexcept
Returns the tag defining the composition of the character.
Definition qchar.h:445
QChar toTitleCase() const noexcept
Returns the title case equivalent if the character is lowercase or uppercase; otherwise returns the c...
Definition qchar.h:450
QChar toUpper() const noexcept
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition qchar.h:449
JoiningType joiningType() const noexcept
Definition qchar.h:438
bool isPunct() const noexcept
Returns true if the character is a punctuation mark (Punctuation_* categories); otherwise returns fal...
Definition qchar.h:468
UnicodeVersion unicodeVersion() const noexcept
Returns the Unicode version that introduced this character.
Definition qchar.h:455
constexpr bool isHighSurrogate() const noexcept
Returns true if the QChar is the high part of a UTF16 surrogate (for example if its code point is in ...
Definition qchar.h:479
bool isSymbol() const noexcept
Returns true if the character is a symbol (Symbol_* categories); otherwise returns false.
Definition qchar.h:469
QDataStream & operator>>(QDataStream &in, QChar &chr)
Reads a char from the stream in into char chr.
Definition qchar.cpp:1724
bool isMark() const noexcept
Returns true if the character is a mark (Mark_* categories); otherwise returns false.
Definition qchar.h:467
static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION
Returns the most recent supported Unicode version.
Definition qchar.cpp:1513
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1101
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
NormalizationForm
This enum describes the various normalized forms of Unicode text.
Definition qstring.h:546
@ NormalizationForm_KC
Definition qstring.h:550
@ NormalizationForm_KD
Definition qstring.h:549
@ NormalizationForm_C
Definition qstring.h:548
@ NormalizationForm_D
Definition qstring.h:547
const QLoggingCategory & category()
[1]
QString str
[2]
QPixmap p2
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
static constexpr unsigned short uc_decomposition_map[]
static Q_DECL_CONST_FUNCTION const Properties * qGetProp(char32_t ucs4) noexcept
static constexpr unsigned short specialCaseMap[]
constexpr unsigned int MaxSpecialCaseLength
static constexpr unsigned short uc_ligature_map[]
#define FLAG(x)
Definition qchar.cpp:23
static constexpr char32_t Hangul_SBase
Definition qchar.cpp:1355
static char32_t ligatureHelper(char32_t u1, char32_t u2)
Definition qchar.cpp:1872
static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1972
static Q_DECL_CONST_FUNCTION T convertCase_helper(T uc, QUnicodeTables::Case which) noexcept
Definition qchar.cpp:1553
static constexpr quint32 Hangul_VCount
Definition qchar.cpp:1360
static constexpr quint32 Hangul_SCount
Definition qchar.cpp:1363
bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2)
Definition qchar.cpp:1853
static auto fullConvertCase(char32_t uc, QUnicodeTables::Case which) noexcept
Definition qchar.cpp:1518
static constexpr quint32 Hangul_NCount
Definition qchar.cpp:1362
static constexpr char32_t Hangul_TBase
Definition qchar.cpp:1358
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1812
static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1912
static constexpr char32_t Hangul_VBase
Definition qchar.cpp:1357
static constexpr quint32 Hangul_TCount
Definition qchar.cpp:1361
static const QChar *QT_FASTCALL decompositionHelper(char32_t ucs4, qsizetype *length, QChar::Decomposition *tag, QChar *buffer)
Definition qchar.cpp:1366
static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, qsizetype from, qsizetype *lastStable)
Definition qchar.cpp:2054
static constexpr quint32 Hangul_LCount
Definition qchar.cpp:1359
static constexpr char32_t Hangul_LBase
Definition qchar.cpp:1356
static char32_t foldCase(const char16_t *ch, const char16_t *start)
Definition qchar.cpp:1632
#define Q_UNLIKELY(x)
#define QT_FASTCALL
#define Q_DECL_CONST_FUNCTION
AudioChannelLayoutTag tag
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLboolean r
[2]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLenum GLuint buffer
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLfixed GLfixed u2
const GLubyte * c
GLuint in
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLfixed u1
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
unsigned int quint32
Definition qtypes.h:45
unsigned char uchar
Definition qtypes.h:27
unsigned short quint16
Definition qtypes.h:43
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned short ushort
Definition qtypes.h:28
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:40
#define GET_LIGATURE_INDEX(ucs4)
#define GET_DECOMPOSITION_INDEX(ucs4)
#define UNICODE_DATA_VERSION
QTextStream out(stdout)
[7]
MyCustomStruct c2
struct QUnicodeTables::Properties::@144 cases[NumCases]
ushort u1
Definition qchar.cpp:1849
ushort u2
Definition qchar.cpp:1850