Qt 4.8
qchar.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 // Don't define it while compiling this module, or USERS of Qt will
43 // not be able to link.
44 #ifdef QT_NO_CAST_FROM_ASCII
45 # undef QT_NO_CAST_FROM_ASCII
46 #endif
47 #ifdef QT_NO_CAST_TO_ASCII
48 # undef QT_NO_CAST_TO_ASCII
49 #endif
50 #include "qchar.h"
51 
52 #include "qdatastream.h"
53 #include "qtextcodec.h"
54 
55 #include "qunicodetables_p.h"
56 #include "qunicodetables.cpp"
57 
59 
60 #ifndef QT_NO_CODEC_FOR_C_STRINGS
61 # ifdef QT_NO_TEXTCODEC
62 # define QT_NO_CODEC_FOR_C_STRINGS
63 # endif
64 #endif
65 
66 #define FLAG(x) (1 << (x))
67 
477 QChar::QChar(char ch)
478 {
479 #ifndef QT_NO_CODEC_FOR_C_STRINGS
481  // #####
483  else
484 #endif
485  ucs = uchar(ch);
486 }
487 
492 {
493 #ifndef QT_NO_CODEC_FOR_C_STRINGS
495  // #####
496  char c = char(ch);
498  } else
499 #endif
500  ucs = ch;
501 }
502 
598 bool QChar::isPrint() const
599 {
600  const int test = FLAG(Other_Control) |
602  return !(FLAG(qGetProp(ucs)->category) & test);
603 }
604 
609 bool QChar::isSpace() const
610 {
611  if(ucs >= 9 && ucs <=13)
612  return true;
613  const int test = FLAG(Separator_Space) |
616  return FLAG(qGetProp(ucs)->category) & test;
617 }
618 
625 bool QChar::isMark() const
626 {
627  const int test = FLAG(Mark_NonSpacing) |
630  return FLAG(qGetProp(ucs)->category) & test;
631 }
632 
637 bool QChar::isPunct() const
638 {
639  const int test = FLAG(Punctuation_Connector) |
646  return FLAG(qGetProp(ucs)->category) & test;
647 }
648 
653 bool QChar::isLetter() const
654 {
655  const int test = FLAG(Letter_Uppercase) |
660  return FLAG(qGetProp(ucs)->category) & test;
661 }
662 
669 bool QChar::isNumber() const
670 {
671  const int test = FLAG(Number_DecimalDigit) |
674  return FLAG(qGetProp(ucs)->category) & test;
675 }
676 
682 {
683  const int test = FLAG(Letter_Uppercase) |
687  FLAG(Letter_Other) |
691  return FLAG(qGetProp(ucs)->category) & test;
692 }
693 
694 
699 bool QChar::isDigit() const
700 {
702 }
703 
704 
709 bool QChar::isSymbol() const
710 {
711  const int test = FLAG(Symbol_Math) |
715  return FLAG(qGetProp(ucs)->category) & test;
716 }
717 
817 int QChar::digitValue() const
818 {
819  return qGetProp(ucs)->digitValue;
820 }
821 
831 {
832  return qGetProp(ucs2)->digitValue;
833 }
834 
844 {
845  if (ucs4 > UNICODE_LAST_CODEPOINT)
846  return 0;
847  return qGetProp(ucs4)->digitValue;
848 }
849 
854 {
856 }
857 
867 {
868  if (ucs4 > UNICODE_LAST_CODEPOINT)
869  return QChar::NoCategory;
870  return (QChar::Category) qGetProp(ucs4)->category;
871 }
872 
881 {
882  return (QChar::Category) qGetProp(ucs2)->category;
883 }
884 
885 
890 {
892 }
893 
902 {
903  if (ucs4 > UNICODE_LAST_CODEPOINT)
904  return QChar::DirL;
905  return (QChar::Direction) qGetProp(ucs4)->direction;
906 }
907 
916 {
917  return (QChar::Direction) qGetProp(ucs2)->direction;
918 }
919 
925 {
926  return (QChar::Joining) qGetProp(ucs)->joining;
927 }
928 
939 {
940  if (ucs4 > UNICODE_LAST_CODEPOINT)
941  return QChar::OtherJoining;
942  return (QChar::Joining) qGetProp(ucs4)->joining;
943 }
944 
955 {
956  return (QChar::Joining) qGetProp(ucs2)->joining;
957 }
958 
959 
968 bool QChar::hasMirrored() const
969 {
970  return qGetProp(ucs)->mirrorDiff != 0;
971 }
972 
1017 {
1018  return ucs + qGetProp(ucs)->mirrorDiff;
1019 }
1020 
1032 {
1033  if (ucs4 > UNICODE_LAST_CODEPOINT)
1034  return ucs4;
1035  return ucs4 + qGetProp(ucs4)->mirrorDiff;
1036 }
1037 
1049 {
1050  return ucs2 + qGetProp(ucs2)->mirrorDiff;
1051 }
1052 
1053 
1054 enum {
1055  Hangul_SBase = 0xac00,
1056  Hangul_LBase = 0x1100,
1057  Hangul_VBase = 0x1161,
1058  Hangul_TBase = 0x11a7,
1059  Hangul_SCount = 11172,
1064 };
1065 
1066 // buffer has to have a length of 3. It's needed for Hangul decomposition
1067 static const unsigned short * QT_FASTCALL decompositionHelper
1068  (uint ucs4, int *length, int *tag, unsigned short *buffer)
1069 {
1070  *length = 0;
1071  if (ucs4 > UNICODE_LAST_CODEPOINT)
1072  return 0;
1073  if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) {
1074  int SIndex = ucs4 - Hangul_SBase;
1075  buffer[0] = Hangul_LBase + SIndex / Hangul_NCount; // L
1076  buffer[1] = Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount; // V
1077  buffer[2] = Hangul_TBase + SIndex % Hangul_TCount; // T
1078  *length = buffer[2] == Hangul_TBase ? 2 : 3;
1079  *tag = QChar::Canonical;
1080  return buffer;
1081  }
1082 
1083  const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1084  if (index == 0xffff)
1085  return 0;
1086  const unsigned short *decomposition = uc_decomposition_map+index;
1087  *tag = (*decomposition) & 0xff;
1088  *length = (*decomposition) >> 8;
1089  return decomposition+1;
1090 }
1091 
1097 {
1098  return decomposition(ucs);
1099 }
1100 
1110 {
1111  unsigned short buffer[3];
1112  int length;
1113  int tag;
1114  const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
1115  return QString::fromUtf16(d, length);
1116 }
1117 
1123 {
1124  return decompositionTag(ucs);
1125 }
1126 
1136 {
1137  if (ucs4 > UNICODE_LAST_CODEPOINT)
1138  return QChar::NoDecomposition;
1139  const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1140  if (index == 0xffff)
1141  return QChar::NoDecomposition;
1143 }
1144 
1153 unsigned char QChar::combiningClass() const
1154 {
1155  return (unsigned char) qGetProp(ucs)->combiningClass;
1156 }
1157 
1166 unsigned char QChar::combiningClass(uint ucs4)
1167 {
1168  if (ucs4 > UNICODE_LAST_CODEPOINT)
1169  return 0;
1170  return (unsigned char) qGetProp(ucs4)->combiningClass;
1171 }
1172 
1181 unsigned char QChar::combiningClass(ushort ucs2)
1182 {
1183  return (unsigned char) qGetProp(ucs2)->combiningClass;
1184 }
1185 
1190 {
1192 }
1193 
1203 {
1204  if (ucs4 > UNICODE_LAST_CODEPOINT)
1207 }
1208 
1218 {
1220 }
1221 
1231 {
1232  return UNICODE_DATA_VERSION;
1233 }
1234 
1240 {
1242  if (!p->lowerCaseSpecial)
1243  return ucs + p->lowerCaseDiff;
1244  return ucs;
1245 }
1246 
1257 {
1258  if (ucs4 > UNICODE_LAST_CODEPOINT)
1259  return ucs4;
1260  const QUnicodeTables::Properties *p = qGetProp(ucs4);
1261  if (!p->lowerCaseSpecial)
1262  return ucs4 + p->lowerCaseDiff;
1263  return ucs4;
1264 }
1265 
1276 {
1277  const QUnicodeTables::Properties *p = qGetProp(ucs2);
1278  if (!p->lowerCaseSpecial)
1279  return ucs2 + p->lowerCaseDiff;
1280  return ucs2;
1281 }
1282 
1288 {
1290  if (!p->upperCaseSpecial)
1291  return ucs + p->upperCaseDiff;
1292  return ucs;
1293 }
1294 
1305 {
1306  if (ucs4 > UNICODE_LAST_CODEPOINT)
1307  return ucs4;
1308  const QUnicodeTables::Properties *p = qGetProp(ucs4);
1309  if (!p->upperCaseSpecial)
1310  return ucs4 + p->upperCaseDiff;
1311  return ucs4;
1312 }
1313 
1324 {
1325  const QUnicodeTables::Properties *p = qGetProp(ucs2);
1326  if (!p->upperCaseSpecial)
1327  return ucs2 + p->upperCaseDiff;
1328  return ucs2;
1329 }
1330 
1336 {
1338  if (!p->titleCaseSpecial)
1339  return ucs + p->titleCaseDiff;
1340  return ucs;
1341 }
1342 
1353 {
1354  if (ucs4 > UNICODE_LAST_CODEPOINT)
1355  return ucs4;
1356  const QUnicodeTables::Properties *p = qGetProp(ucs4);
1357  if (!p->titleCaseSpecial)
1358  return ucs4 + p->titleCaseDiff;
1359  return ucs4;
1360 }
1361 
1372 {
1373  const QUnicodeTables::Properties *p = qGetProp(ucs2);
1374  if (!p->titleCaseSpecial)
1375  return ucs2 + p->titleCaseDiff;
1376  return ucs2;
1377 }
1378 
1379 
1380 static inline uint foldCase(const ushort *ch, const ushort *start)
1381 {
1382  uint c = *ch;
1383  if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate())
1384  c = QChar::surrogateToUcs4(*(ch - 1), c);
1385  return *ch + qGetProp(c)->caseFoldDiff;
1386 }
1387 
1388 static inline uint foldCase(uint ch, uint &last)
1389 {
1390  uint c = ch;
1391  if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
1392  c = QChar::surrogateToUcs4(last, c);
1393  last = ch;
1394  return ch + qGetProp(c)->caseFoldDiff;
1395 }
1396 
1397 static inline ushort foldCase(ushort ch)
1398 {
1399  return ch + qGetProp(ch)->caseFoldDiff;
1400 }
1401 
1407 {
1408  return ucs + qGetProp(ucs)->caseFoldDiff;
1409 }
1410 
1420 {
1421  if (ucs4 > UNICODE_LAST_CODEPOINT)
1422  return ucs4;
1423  return ucs4 + qGetProp(ucs4)->caseFoldDiff;
1424 }
1425 
1435 {
1436  return ucs2 + qGetProp(ucs2)->caseFoldDiff;
1437 }
1438 
1439 
1487 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE
1488 const char QChar::toAscii() const
1489 #else
1490 char QChar::toAscii() const
1491 #endif
1492 {
1493 #ifndef QT_NO_CODEC_FOR_C_STRINGS
1495  // #####
1496  return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0);
1497 #endif
1498  return ucs > 0xff ? 0 : char(ucs);
1499 }
1500 
1522 {
1523 #ifndef QT_NO_CODEC_FOR_C_STRINGS
1525  // #####
1526  return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
1527 #endif
1528  return QChar(ushort((uchar)c));
1529 }
1530 
1531 #ifndef QT_NO_DATASTREAM
1532 
1543 {
1544  out << quint16(chr.unicode());
1545  return out;
1546 }
1547 
1559 {
1560  quint16 u;
1561  in >> u;
1562  chr.unicode() = ushort(u);
1563  return in;
1564 }
1565 #endif // QT_NO_DATASTREAM
1566 
1582 /*****************************************************************************
1583  Documentation of QChar related functions
1584  *****************************************************************************/
1585 
1695 // ---------------------------------------------------------------------------
1696 
1697 
1698 static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from)
1699 {
1700  unsigned short buffer[3];
1701 
1702  QString &s = *str;
1703 
1704  const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data());
1705  const unsigned short *uc = utf16 + s.length();
1706  while (uc != utf16 + from) {
1707  uint ucs4 = *(--uc);
1708  if (QChar(ucs4).isLowSurrogate() && uc != utf16) {
1709  ushort high = *(uc - 1);
1710  if (QChar(high).isHighSurrogate()) {
1711  --uc;
1712  ucs4 = QChar::surrogateToUcs4(high, ucs4);
1713  }
1714  }
1716  if (v == QChar::Unicode_Unassigned || v > version)
1717  continue;
1718  int length;
1719  int tag;
1720  const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer);
1721  if (!d || (canonical && tag != QChar::Canonical))
1722  continue;
1723 
1724  int pos = uc - utf16;
1725  s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
1726  // since the insert invalidates the pointers and we do decomposition recursive
1727  utf16 = reinterpret_cast<unsigned short *>(s.data());
1728  uc = utf16 + pos + length;
1729  }
1730 }
1731 
1732 
1733 struct UCS2Pair {
1736 };
1737 
1738 inline bool operator<(ushort u1, const UCS2Pair &ligature)
1739 { return u1 < ligature.u1; }
1740 inline bool operator<(const UCS2Pair &ligature, ushort u1)
1741 { return ligature.u1 < u1; }
1742 
1744 {
1745  // hangul L-V pair
1746  int LIndex = u1 - Hangul_LBase;
1747  if (0 <= LIndex && LIndex < Hangul_LCount) {
1748  int VIndex = u2 - Hangul_VBase;
1749  if (0 <= VIndex && VIndex < Hangul_VCount)
1750  return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
1751  }
1752 
1753  // hangul LV-T pair
1754  int SIndex = u1 - Hangul_SBase;
1755  if (0 <= SIndex && SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
1756  int TIndex = u2 - Hangul_TBase;
1757  if (0 <= TIndex && TIndex <= Hangul_TCount)
1758  return u1 + TIndex;
1759  }
1760 
1761  const unsigned short index = GET_LIGATURE_INDEX(u2);
1762  if (index == 0xffff)
1763  return 0;
1764  const unsigned short *ligatures = uc_ligature_map+index;
1765  ushort length = *ligatures++;
1766  {
1767  const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures);
1768  const UCS2Pair *r = qBinaryFind(data, data + length, u1);
1769  if (r != data + length)
1770  return r->u2;
1771  }
1772 
1773  return 0;
1774 }
1775 
1776 static void composeHelper(QString *str, QChar::UnicodeVersion version, int from)
1777 {
1778  QString &s = *str;
1779 
1780  if (from < 0 || s.length() - from < 2)
1781  return;
1782 
1783  // the loop can partly ignore high Unicode as all ligatures are in the BMP
1784  int starter = -2; // to prevent starter == pos - 1
1785  int lastCombining = 255; // to prevent combining > lastCombining
1786  int pos = from;
1787  while (pos < s.length()) {
1788  uint uc = s.at(pos).unicode();
1789  if (QChar(uc).isHighSurrogate() && pos < s.length()-1) {
1790  ushort low = s.at(pos+1).unicode();
1791  if (QChar(low).isLowSurrogate()) {
1792  uc = QChar::surrogateToUcs4(uc, low);
1793  ++pos;
1794  }
1795  }
1796  const QUnicodeTables::Properties *p = qGetProp(uc);
1797  if (p->unicodeVersion == QChar::Unicode_Unassigned || p->unicodeVersion > version) {
1798  starter = -1; // to prevent starter == pos - 1
1799  lastCombining = 255; // to prevent combining > lastCombining
1800  ++pos;
1801  continue;
1802  }
1803  int combining = p->combiningClass;
1804  if ((starter == pos - 1 || combining > lastCombining) && starter >= from) {
1805  // allowed to form ligature with S
1806  QChar ligature = ligatureHelper(s.at(starter).unicode(), uc);
1807  if (ligature.unicode()) {
1808  s[starter] = ligature;
1809  s.remove(pos, 1);
1810  continue;
1811  }
1812  }
1813  if (!combining)
1814  starter = pos;
1815  lastCombining = combining;
1816  ++pos;
1817  }
1818 }
1819 
1820 
1821 static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, int from)
1822 {
1823  QString &s = *str;
1824  const int l = s.length()-1;
1825  int pos = from;
1826  while (pos < l) {
1827  int p2 = pos+1;
1828  uint u1 = s.at(pos).unicode();
1829  if (QChar(u1).isHighSurrogate()) {
1830  ushort low = s.at(p2).unicode();
1831  if (QChar(low).isLowSurrogate()) {
1832  u1 = QChar::surrogateToUcs4(u1, low);
1833  if (p2 >= l)
1834  break;
1835  ++p2;
1836  }
1837  }
1838  uint u2 = s.at(p2).unicode();
1839  if (QChar(u2).isHighSurrogate() && p2 < l) {
1840  ushort low = s.at(p2+1).unicode();
1841  if (QChar(low).isLowSurrogate()) {
1842  u2 = QChar::surrogateToUcs4(u2, low);
1843  ++p2;
1844  }
1845  }
1846 
1847  ushort c2 = 0;
1848  {
1849  const QUnicodeTables::Properties *p = qGetProp(u2);
1850  if (p->unicodeVersion != QChar::Unicode_Unassigned && p->unicodeVersion <= version)
1851  c2 = p->combiningClass;
1852  }
1853  if (c2 == 0) {
1854  pos = p2+1;
1855  continue;
1856  }
1857 
1858  ushort c1 = 0;
1859  {
1860  const QUnicodeTables::Properties *p = qGetProp(u1);
1861  if (p->unicodeVersion != QChar::Unicode_Unassigned && p->unicodeVersion <= version)
1862  c1 = p->combiningClass;
1863  }
1864 
1865  if (c1 > c2) {
1866  QChar *uc = s.data();
1867  int p = pos;
1868  // exchange characters
1869  if (!QChar::requiresSurrogates(u2)) {
1870  uc[p++] = u2;
1871  } else {
1872  uc[p++] = QChar::highSurrogate(u2);
1873  uc[p++] = QChar::lowSurrogate(u2);
1874  }
1875  if (!QChar::requiresSurrogates(u1)) {
1876  uc[p++] = u1;
1877  } else {
1878  uc[p++] = QChar::highSurrogate(u1);
1879  uc[p++] = QChar::lowSurrogate(u1);
1880  }
1881  if (pos > 0)
1882  --pos;
1883  if (pos > 0 && s.at(pos).isLowSurrogate())
1884  --pos;
1885  } else {
1886  ++pos;
1887  if (QChar::requiresSurrogates(u1))
1888  ++pos;
1889  }
1890  }
1891 }
1892 
double d
Definition: qnumeric_p.h:62
#define UNICODE_DATA_VERSION
Joining
This enum type defines the Unicode joining attributes.
Definition: qchar.h:182
bool isLetter() const
Returns true if the character is a letter (Letter_* categories); otherwise returns false...
Definition: qchar.cpp:653
Category
This enum maps the Unicode character categories.
Definition: qchar.h:106
unsigned char c[8]
Definition: qnumeric_p.h:62
QChar()
Constructs a null QChar (&#39;\0&#39;).
Definition: qchar.h:371
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static ushort ligatureHelper(ushort u1, ushort u2)
Definition: qchar.cpp:1743
int digitValue() const
Returns the numeric value of the digit, or -1 if the character is not a digit.
Definition: qchar.cpp:817
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
ushort ucs
Definition: qchar.h:362
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
static QTextCodec * codecForCStrings()
Returns the codec used by QString to convert to and from const char * and QByteArrays.
Definition: qtextcodec.h:157
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
Decomposition decompositionTag() const
Returns the tag defining the composition of the character.
Definition: qchar.cpp:1122
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
Definition: qchar.h:279
Joining joining() const
Returns information about the joining properties of the character (needed for certain languages such ...
Definition: qchar.cpp:924
int operator<(QChar c1, QChar c2)
Returns true if the numeric Unicode value of c1 is less than that of c2; otherwise returns false...
Definition: qchar.h:396
quint16 u
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
ushort u1
Definition: qchar.cpp:1734
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isSymbol() const
Returns true if the character is a symbol (Symbol_* categories); otherwise returns false...
Definition: qchar.cpp:709
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
Definition: qchar.h:276
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
Definition: qchar.cpp:598
QChar toCaseFolded() const
Returns the case folded equivalent of the character.
Definition: qchar.cpp:1406
#define QT_FASTCALL
Definition: qglobal.h:1161
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
#define GET_DECOMPOSITION_INDEX(ucs4)
#define GET_LIGATURE_INDEX(u2)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
static ushort highSurrogate(uint ucs4)
Returns the high surrogate value of a ucs4 code point.
Definition: qchar.h:303
static ushort lowSurrogate(uint ucs4)
Returns the low surrogate value of a ucs4 code point.
Definition: qchar.h:306
UnicodeVersion unicodeVersion() const
Returns the Unicode version that introduced this character.
Definition: qchar.cpp:1189
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from)
Definition: qchar.cpp:1698
unsigned char uchar
Definition: qglobal.h:994
bool hasMirrored() const
Returns true if the character should be reversed if the text direction is reversed; otherwise returns...
Definition: qchar.cpp:968
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool requiresSurrogates(uint ucs4)
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
Definition: qchar.h:294
#define UNICODE_LAST_CODEPOINT
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
QChar mirroredChar() const
Returns the mirrored character if this character is a mirrored character; otherwise returns the chara...
Definition: qchar.cpp:1016
static const QUnicodeTables::Properties * qGetProp(uint ucs4)
bool isPunct() const
Returns true if the character is a punctuation mark (Punctuation_* categories); otherwise returns fal...
Definition: qchar.cpp:637
unsigned short quint16
Definition: qglobal.h:936
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
QDataStream & operator>>(QDataStream &in, QChar &chr)
Reads a char from the stream in into char chr.
Definition: qchar.cpp:1558
UnicodeVersion
Specifies which version of the [Unicode standard](http://www.
Definition: qchar.h:212
QChar toTitleCase() const
Returns the title case equivalent if the character is lowercase or uppercase; otherwise returns the c...
Definition: qchar.cpp:1335
char toAscii() const
Returns the character value of the QChar obtained using the current codec used to read C strings...
Definition: qchar.cpp:1490
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
#define FLAG(x)
Definition: qchar.cpp:66
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
ushort u2
Definition: qchar.cpp:1735
Direction
This enum type defines the Unicode direction attributes.
Definition: qchar.h:150
unsigned short ushort
Definition: qglobal.h:995
QFactoryLoader * l
static uint surrogateToUcs4(ushort high, ushort low)
Converts a UTF16 surrogate pair with the given high and low values to its UCS-4 code point...
Definition: qchar.h:297
quint16 index
bool isMark() const
Returns true if the character is a mark (Mark_* categories); otherwise returns false.
Definition: qchar.cpp:625
static void composeHelper(QString *str, QChar::UnicodeVersion version, int from)
Definition: qchar.cpp:1776
static const unsigned short uc_ligature_map[]
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
static const unsigned short uc_decomposition_map[]
static UnicodeVersion QT_FASTCALL currentUnicodeVersion()
Returns the most recent supported Unicode version.
Definition: qchar.cpp:1230
Direction direction() const
Returns the character&#39;s direction.
Definition: qchar.cpp:889
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
unsigned char combiningClass() const
Returns the combining class for the character as defined in the Unicode standard. ...
Definition: qchar.cpp:1153
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, int from)
Definition: qchar.cpp:1821
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521
QString decomposition() const
Decomposes a character into its parts.
Definition: qchar.cpp:1096
QDataStream & operator<<(QDataStream &out, const QChar &chr)
Writes the char chr to the stream out.
Definition: qchar.cpp:1542
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
bool isNumber() const
Returns true if the character is a number (Number_* categories, not just 0-9); otherwise returns fals...
Definition: qchar.cpp:669
bool isDigit() const
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false...
Definition: qchar.cpp:699
static QString fromUtf16(const ushort *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...
Definition: qstring.cpp:4329
bool isLetterOrNumber() const
Returns true if the character is a letter or number (Letter_* or Number_* categories); otherwise retu...
Definition: qchar.cpp:681
Decomposition
This enum type defines the Unicode decomposition attributes.
Definition: qchar.h:156
static const unsigned short *QT_FASTCALL decompositionHelper(uint ucs4, int *length, int *tag, unsigned short *buffer)
Definition: qchar.cpp:1068