Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:critical reason:data-parser
4
5#include "qchar.h"
6
9
10#include <algorithm>
11
12QT_BEGIN_NAMESPACE
13
14#define FLAG(x) (1 << (x))
15
16/*!
17 \class QLatin1Char
18 \inmodule QtCore
19 \reentrant
20 \brief The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
21
22 \ingroup string-processing
23
24 This class is only useful to construct a QChar with 8-bit character.
25
26 \sa QChar, QLatin1StringView, QString
27*/
28
29/*!
30 \fn const char QLatin1Char::toLatin1() const
31
32 Converts a Latin-1 character to an 8-bit ASCII representation of the character.
33*/
34
35/*!
36 \fn QLatin1Char::unicode() const
37
38 Converts a Latin-1 character to an 16-bit-encoded Unicode representation
39 of the character.
40*/
41
42/*!
43 \fn QLatin1Char::QLatin1Char(char c)
44
45 Constructs a Latin-1 character for \a c. This constructor should be
46 used when the encoding of the input character is known to be Latin-1.
47*/
48
49/*!
50 \class QChar
51 \inmodule QtCore
52 \brief The QChar class provides a 16-bit Unicode character.
53
54 \ingroup string-processing
55 \reentrant
56
57 \compares strong
58 \compareswith strong char16_t QString QStringView QLatin1StringView QUtf8StringView
59 \endcompareswith
60 \compareswith strong {const char *} QByteArray QByteArrayView
61 The contents of the byte array is interpreted as UTF-8.
62 \endcompareswith
63
64 In Qt, Unicode characters are 16-bit entities without any markup
65 or structure. This class represents such an entity. It is
66 lightweight, so it can be used everywhere. Most compilers treat
67 it like an \c{unsigned short}.
68
69 QChar provides a full complement of testing/classification
70 functions, converting to and from other formats, converting from
71 composed to decomposed Unicode, and trying to compare and
72 case-convert if you ask it to.
73
74 The classification functions include functions like those in the
75 standard C++ header <cctype> (formerly <ctype.h>), but
76 operating on the full range of Unicode characters, not just for the ASCII
77 range. They all return true if the character is a certain type of character;
78 otherwise they return false. These classification functions are
79 isNull() (returns \c true if the character is '\\0'), isPrint()
80 (true if the character is any sort of printable character,
81 including whitespace), isPunct() (any sort of punctation),
82 isMark() (Unicode Mark), isLetter() (a letter), isNumber() (any
83 sort of numeric character, not just 0-9), isLetterOrNumber(), and
84 isDigit() (decimal digits). All of these are wrappers around
85 category() which return the Unicode-defined category of each
86 character. Some of these also calculate the derived properties
87 (for example isSpace() returns \c true if the character is of category
88 Separator_* or an exceptional code point from Other_Control category).
89
90 QChar also provides direction(), which indicates the "natural"
91 writing direction of this character. The joiningType() function
92 indicates how the character joins with it's neighbors (needed
93 mostly for Arabic or Syriac) and finally hasMirrored(), which indicates
94 whether the character needs to be mirrored when it is printed in
95 it's "unnatural" writing direction.
96
97 Composed Unicode characters (like \a ring) can be converted to
98 decomposed Unicode ("a" followed by "ring above") by using decomposition().
99
100 In Unicode, comparison is not necessarily possible and case
101 conversion is very difficult at best. Unicode, covering the
102 "entire" world, also includes most of the world's case and
103 sorting problems. operator==() and friends will do comparison
104 based purely on the numeric Unicode value (code point) of the
105 characters, and toUpper() and toLower() will do case changes when
106 the character has a well-defined uppercase/lowercase equivalent.
107 For locale-dependent comparisons, use QString::localeAwareCompare().
108
109 The conversion functions include unicode() (to a scalar),
110 toLatin1() (to scalar, but converts all non-Latin-1 characters to
111 0), row() (gives the Unicode row), cell() (gives the Unicode
112 cell), digitValue() (gives the integer value of any of the
113 numerous digit characters), and a host of constructors.
114
115 QChar provides constructors and cast operators that make it easy
116 to convert to and from traditional 8-bit \c{char}s. If you
117 defined \c QT_NO_CAST_FROM_ASCII and \c QT_NO_CAST_TO_ASCII, as
118 explained in the QString documentation, you will need to
119 explicitly call fromLatin1(), or use QLatin1Char,
120 to construct a QChar from an 8-bit \c char, and you will need to
121 call toLatin1() to get the 8-bit value back.
122
123 Starting with Qt 6.0, most QChar constructors are \c explicit. This
124 is done to avoid dangerous mistakes when accidentally mixing
125 integral types and strings.
126
127 For more information see
128 \l{https://www.unicode.org/ucd/}{"About the Unicode Character Database"}.
129
130 \sa Unicode, QString, QLatin1Char
131*/
132
133/*!
134 \enum QChar::UnicodeVersion
135
136 Specifies which version of the \l{Unicode standard} introduced a certain
137 character.
138
139 \value Unicode_1_1 Version 1.1
140 \value Unicode_2_0 Version 2.0
141 \value Unicode_2_1_2 Version 2.1.2
142 \value Unicode_3_0 Version 3.0
143 \value Unicode_3_1 Version 3.1
144 \value Unicode_3_2 Version 3.2
145 \value Unicode_4_0 Version 4.0
146 \value Unicode_4_1 Version 4.1
147 \value Unicode_5_0 Version 5.0
148 \value Unicode_5_1 Version 5.1
149 \value Unicode_5_2 Version 5.2
150 \value Unicode_6_0 Version 6.0
151 \value Unicode_6_1 Version 6.1
152 \value Unicode_6_2 Version 6.2
153 \value [since 5.3] Unicode_6_3 Version 6.3
154 \value [since 5.5] Unicode_7_0 Version 7.0
155 \value [since 5.6] Unicode_8_0 Version 8.0
156 \value [since 5.11] Unicode_9_0 Version 9.0
157 \value [since 5.11] Unicode_10_0 Version 10.0
158 \value [since 5.15] Unicode_11_0 Version 11.0
159 \value [since 5.15] Unicode_12_0 Version 12.0
160 \value [since 5.15] Unicode_12_1 Version 12.1
161 \value [since 5.15] Unicode_13_0 Version 13.0
162 \value [since 6.3] Unicode_14_0 Version 14.0
163 \value [since 6.5] Unicode_15_0 Version 15.0
164 \value [since 6.8] Unicode_15_1 Version 15.1
165 \value [since 6.9] Unicode_16_0 Version 16.0
166 \value Unicode_Unassigned The value is not assigned to any character
167 in version 8.0 of Unicode.
168
169 \sa unicodeVersion(), currentUnicodeVersion()
170*/
171
172/*!
173 \enum QChar::Category
174
175 This enum maps the Unicode character categories.
176
177 The following characters are normative in Unicode:
178
179 \value Mark_NonSpacing Unicode class name Mn
180
181 \value Mark_SpacingCombining Unicode class name Mc
182
183 \value Mark_Enclosing Unicode class name Me
184
185 \value Number_DecimalDigit Unicode class name Nd
186
187 \value Number_Letter Unicode class name Nl
188
189 \value Number_Other Unicode class name No
190
191 \value Separator_Space Unicode class name Zs
192
193 \value Separator_Line Unicode class name Zl
194
195 \value Separator_Paragraph Unicode class name Zp
196
197 \value Other_Control Unicode class name Cc
198
199 \value Other_Format Unicode class name Cf
200
201 \value Other_Surrogate Unicode class name Cs
202
203 \value Other_PrivateUse Unicode class name Co
204
205 \value Other_NotAssigned Unicode class name Cn
206
207
208 The following categories are informative in Unicode:
209
210 \value Letter_Uppercase Unicode class name Lu
211
212 \value Letter_Lowercase Unicode class name Ll
213
214 \value Letter_Titlecase Unicode class name Lt
215
216 \value Letter_Modifier Unicode class name Lm
217
218 \value Letter_Other Unicode class name Lo
219
220 \value Punctuation_Connector Unicode class name Pc
221
222 \value Punctuation_Dash Unicode class name Pd
223
224 \value Punctuation_Open Unicode class name Ps
225
226 \value Punctuation_Close Unicode class name Pe
227
228 \value Punctuation_InitialQuote Unicode class name Pi
229
230 \value Punctuation_FinalQuote Unicode class name Pf
231
232 \value Punctuation_Other Unicode class name Po
233
234 \value Symbol_Math Unicode class name Sm
235
236 \value Symbol_Currency Unicode class name Sc
237
238 \value Symbol_Modifier Unicode class name Sk
239
240 \value Symbol_Other Unicode class name So
241
242 \sa category()
243*/
244
245/*!
246 \enum QChar::Script
247 \since 5.1
248
249 This enum type defines the Unicode script property values.
250
251 For details about the Unicode script property values see
252 \l{https://www.unicode.org/reports/tr24/}{Unicode Standard Annex #24}.
253
254 In order to conform to C/C++ naming conventions "Script_" is prepended
255 to the codes used in the Unicode Standard.
256
257 \value Script_Unknown For unassigned, private-use, noncharacter, and surrogate code points.
258 \value Script_Inherited For characters that may be used with multiple scripts
259 and that inherit their script from the preceding characters.
260 These include nonspacing marks, enclosing marks,
261 and zero width joiner/non-joiner characters.
262 \value Script_Common For characters that may be used with multiple scripts
263 and that do not inherit their script from the preceding characters.
264
265 \value [since 5.11] Script_Adlam
266 \value [since 5.6] Script_Ahom
267 \value [since 5.6] Script_AnatolianHieroglyphs
268 \value Script_Arabic
269 \value Script_Armenian
270 \value Script_Avestan
271 \value Script_Balinese
272 \value Script_Bamum
273 \value [since 5.5] Script_BassaVah
274 \value Script_Batak
275 \value Script_Bengali
276 \value [since 5.11] Script_Bhaiksuki
277 \value Script_Bopomofo
278 \value Script_Brahmi
279 \value Script_Braille
280 \value Script_Buginese
281 \value Script_Buhid
282 \value Script_CanadianAboriginal
283 \value Script_Carian
284 \value [since 5.5] Script_CaucasianAlbanian
285 \value Script_Chakma
286 \value Script_Cham
287 \value Script_Cherokee
288 \value [since 5.15] Script_Chorasmian
289 \value Script_Coptic
290 \value Script_Cuneiform
291 \value Script_Cypriot
292 \value [since 6.3] Script_CyproMinoan
293 \value Script_Cyrillic
294 \value Script_Deseret
295 \value Script_Devanagari
296 \value [since 5.15] Script_DivesAkuru
297 \value [since 5.15] Script_Dogra
298 \value [since 5.5] Script_Duployan
299 \value Script_EgyptianHieroglyphs
300 \value [since 5.5] Script_Elbasan
301 \value [since 5.15] Script_Elymaic
302 \value Script_Ethiopic
303 \value [since 6.9] Script_Garay
304 \value Script_Georgian
305 \value Script_Glagolitic
306 \value Script_Gothic
307 \value [since 5.5] Script_Grantha
308 \value Script_Greek
309 \value Script_Gujarati
310 \value [since 5.15] Script_GunjalaGondi
311 \value Script_Gurmukhi
312 \value [since 6.9] Script_GurungKhema
313 \value Script_Han
314 \value Script_Hangul
315 \value [since 5.15] Script_HanifiRohingya
316 \value Script_Hanunoo
317 \value [since 5.6] Script_Hatran
318 \value Script_Hebrew
319 \value Script_Hiragana
320 \value Script_ImperialAramaic
321 \value Script_InscriptionalPahlavi
322 \value Script_InscriptionalParthian
323 \value Script_Javanese
324 \value Script_Kaithi
325 \value Script_Kannada
326 \value Script_Katakana
327 \value [since 6.5] Script_Kawi
328 \value Script_KayahLi
329 \value Script_Kharoshthi
330 \value [since 5.15] Script_KhitanSmallScript
331 \value Script_Khmer
332 \value [since 5.5] Script_Khojki
333 \value [since 5.5] Script_Khudawadi
334 \value [since 6.9] Script_KiratRai
335 \value Script_Lao
336 \value Script_Latin
337 \value Script_Lepcha
338 \value Script_Limbu
339 \value [since 5.5] Script_LinearA
340 \value Script_LinearB
341 \value Script_Lisu
342 \value Script_Lycian
343 \value Script_Lydian
344 \value [since 5.5] Script_Mahajani
345 \value [since 5.15] Script_Makasar
346 \value Script_Malayalam
347 \value Script_Mandaic
348 \value [since 5.5] Script_Manichaean
349 \value [since 5.11] Script_Marchen
350 \value [since 5.11] Script_MasaramGondi
351 \value [since 5.15] Script_Medefaidrin
352 \value Script_MeeteiMayek
353 \value [since 5.5] Script_MendeKikakui
354 \value Script_MeroiticCursive
355 \value Script_MeroiticHieroglyphs
356 \value Script_Miao
357 \value [since 5.5] Script_Modi
358 \value Script_Mongolian
359 \value [since 5.5] Script_Mro
360 \value [since 5.6] Script_Multani
361 \value Script_Myanmar
362 \value [since 5.5] Script_Nabataean
363 \value [since 6.3] Script_NagMundari
364 \value [since 5.15] Script_Nandinagari
365 \value [since 5.11] Script_Newa
366 \value Script_NewTaiLue
367 \value Script_Nko
368 \value [since 5.11] Script_Nushu
369 \value [since 5.15] Script_NyiakengPuachueHmong
370 \value Script_Ogham
371 \value Script_OlChiki
372 \value [since 6.9] Script_OlOnal
373 \value [since 5.6] Script_OldHungarian
374 \value Script_OldItalic
375 \value [since 5.5] Script_OldNorthArabian
376 \value [since 5.5] Script_OldPermic
377 \value Script_OldPersian
378 \value [since 5.15] Script_OldSogdian
379 \value Script_OldSouthArabian
380 \value Script_OldTurkic
381 \value [since 6.3] Script_OldUyghur
382 \value Script_Oriya
383 \value [since 5.11] Script_Osage
384 \value Script_Osmanya
385 \value [since 5.5] Script_PahawhHmong
386 \value [since 5.5] Script_Palmyrene
387 \value [since 5.5] Script_PauCinHau
388 \value Script_PhagsPa
389 \value Script_Phoenician
390 \value [since 5.5] Script_PsalterPahlavi
391 \value Script_Rejang
392 \value Script_Runic
393 \value Script_Samaritan
394 \value Script_Saurashtra
395 \value Script_Sharada
396 \value Script_Shavian
397 \value [since 5.5] Script_Siddham
398 \value [since 5.6] Script_SignWriting
399 \value Script_Sinhala
400 \value [since 5.15] Script_Sogdian
401 \value Script_SoraSompeng
402 \value [since 5.11] Script_Soyombo
403 \value Script_Sundanese
404 \value [since 6.9] Script_Sunuwar
405 \value Script_SylotiNagri
406 \value Script_Syriac
407 \value Script_Tagalog
408 \value Script_Tagbanwa
409 \value Script_TaiLe
410 \value Script_TaiTham
411 \value Script_TaiViet
412 \value Script_Takri
413 \value Script_Tamil
414 \value [since 5.11] Script_Tangut
415 \value [since 6.3] Script_Tangsa
416 \value Script_Telugu
417 \value Script_Thaana
418 \value Script_Thai
419 \value Script_Tibetan
420 \value Script_Tifinagh
421 \value [since 5.5] Script_Tirhuta
422 \value [since 6.9] Script_Todhri
423 \value [since 6.3] Script_Toto
424 \value [since 6.9] Script_TuluTigalari
425 \value Script_Ugaritic
426 \value Script_Vai
427 \value [since 6.3] Script_Vithkuqi
428 \value [since 5.15] Script_Wancho
429 \value [since 5.5] Script_WarangCiti
430 \value [since 5.15] Script_Yezidi
431 \value Script_Yi
432 \value [since 5.11] Script_ZanabazarSquare
433
434 \omitvalue ScriptCount
435
436 \sa script()
437*/
438
439/*!
440 \enum QChar::Direction
441
442 This enum type defines the Unicode direction attributes. See the
443 \l{https://www.unicode.org/reports/tr9/tr9-35.html#Table_Bidirectional_Character_Types}{Unicode
444 Standard} for a description of the values.
445
446 In order to conform to C/C++ naming conventions "Dir" is prepended
447 to the codes used in the Unicode Standard.
448
449 \value DirAL
450 \value DirAN
451 \value DirB
452 \value DirBN
453 \value DirCS
454 \value DirEN
455 \value DirES
456 \value DirET
457 \value [since 5.3] DirFSI
458 \value DirL
459 \value DirLRE
460 \value [since 5.3] DirLRI
461 \value DirLRO
462 \value DirNSM
463 \value DirON
464 \value DirPDF
465 \value [since 5.3] DirPDI
466 \value DirR
467 \value DirRLE
468 \value [since 5.3] DirRLI
469 \value DirRLO
470 \value DirS
471 \value DirWS
472
473 \sa direction()
474*/
475
476/*!
477 \enum QChar::Decomposition
478
479 This enum type defines the Unicode decomposition attributes. See
480 the \l{Unicode standard} for a description of the values.
481
482 \value NoDecomposition
483 \value Canonical
484 \value Circle
485 \value Compat
486 \value Final
487 \value Font
488 \value Fraction
489 \value Initial
490 \value Isolated
491 \value Medial
492 \value Narrow
493 \value NoBreak
494 \value Small
495 \value Square
496 \value Sub
497 \value Super
498 \value Vertical
499 \value Wide
500
501 \sa decomposition()
502*/
503
504/*!
505 \enum QChar::JoiningType
506 since 5.3
507
508 This enum type defines the Unicode joining type attributes. See the
509 \l{Unicode standard} for a description of the values.
510
511 In order to conform to C/C++ naming conventions "Joining_" is prepended
512 to the codes used in the Unicode Standard.
513
514 \value Joining_None
515 \value Joining_Causing
516 \value Joining_Dual
517 \value Joining_Right
518 \value Joining_Left
519 \value Joining_Transparent
520
521 \sa joiningType()
522*/
523
524/*!
525 \enum QChar::CombiningClass
526
527 \internal
528
529 This enum type defines names for some of the Unicode combining
530 classes. See the \l{Unicode Standard} for a description of the values.
531
532 \value Combining_Above
533 \value Combining_AboveAttached
534 \value Combining_AboveLeft
535 \value Combining_AboveLeftAttached
536 \value Combining_AboveRight
537 \value Combining_AboveRightAttached
538 \value Combining_Below
539 \value Combining_BelowAttached
540 \value Combining_BelowLeft
541 \value Combining_BelowLeftAttached
542 \value Combining_BelowRight
543 \value Combining_BelowRightAttached
544 \value Combining_DoubleAbove
545 \value Combining_DoubleBelow
546 \value Combining_IotaSubscript
547 \value Combining_Left
548 \value Combining_LeftAttached
549 \value Combining_Right
550 \value Combining_RightAttached
551*/
552
553/*!
554 \enum QChar::SpecialCharacter
555
556 \value Null A QChar with this value isNull().
557 \value Tabulation Character tabulation.
558 \value LineFeed
559 \value FormFeed
560 \value CarriageReturn
561 \value Space
562 \value Nbsp Non-breaking space.
563 \value SoftHyphen
564 \value ReplacementCharacter The character shown when a font has no glyph
565 for a certain codepoint. A special question mark character is often
566 used. Codecs use this codepoint when input data cannot be
567 represented in Unicode.
568 \value ObjectReplacementCharacter Used to represent an object such as an
569 image when such objects cannot be presented.
570 \value ByteOrderMark
571 \value ByteOrderSwapped
572 \value ParagraphSeparator
573 \value LineSeparator
574 \value [since 6.2] VisualTabCharacter Used to represent a tabulation as a horizontal arrow.
575 \value LastValidCodePoint
576*/
577
578/*!
579 \fn void QChar::setCell(uchar cell)
580 \internal
581*/
582
583/*!
584 \fn void QChar::setRow(uchar row)
585 \internal
586*/
587
588/*!
589 \fn QChar::QChar()
590
591 Constructs a null QChar ('\\0').
592
593 \sa isNull()
594*/
595
596/*!
597 \fn QChar::QChar(QLatin1Char ch)
598
599 Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
600
601//![qchar-implicit-conversions]
602 \note Since Qt 6.9, implicit conversions are disabled for this constructor.
603 That means it accepts only the constructor argument type and not everything
604 that implicitly converts to it. A backwards-compatible fix is to explicitly
605 cast to one of the supported argument types of QChar constructors.
606//![qchar-implicit-conversions]
607*/
608
609/*!
610 \fn QChar::QChar(SpecialCharacter ch)
611
612 Constructs a QChar for the predefined character value \a ch.
613
614 \include qchar.cpp qchar-implicit-conversions
615*/
616
617/*!
618 \fn QChar::QChar(char16_t ch)
619 \since 5.10
620
621 Constructs a QChar corresponding to the UTF-16 character \a ch.
622
623 \include qchar.cpp qchar-implicit-conversions
624*/
625
626/*!
627 \fn QChar::QChar(wchar_t ch)
628 \since 5.10
629
630 Constructs a QChar corresponding to the wide character \a ch.
631
632 \note This constructor is only available on Windows.
633
634 \include qchar.cpp qchar-implicit-conversions
635*/
636
637/*!
638 \fn QChar::QChar(char ch)
639
640 Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
641
642 \note This constructor is not available when \c QT_NO_CAST_FROM_ASCII
643 is defined.
644
645 \include qchar.cpp qchar-implicit-conversions
646
647 \sa QT_NO_CAST_FROM_ASCII
648*/
649
650/*!
651 \fn QChar::QChar(uchar ch)
652
653 Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
654
655 \note This constructor is not available when \c QT_NO_CAST_FROM_ASCII
656 or \c QT_RESTRICTED_CAST_FROM_ASCII is defined.
657
658 \include qchar.cpp qchar-implicit-conversions
659
660 \sa QT_NO_CAST_FROM_ASCII, QT_RESTRICTED_CAST_FROM_ASCII
661*/
662
663/*!
664 \fn QChar::QChar(uchar cell, uchar row)
665
666 Constructs a QChar for Unicode cell \a cell in row \a row.
667
668 \sa cell(), row()
669*/
670
671/*!
672 \fn QChar::QChar(ushort code)
673
674 Constructs a QChar for the character with Unicode code point \a code.
675
676 \include qchar.cpp qchar-implicit-conversions
677*/
678
679/*!
680 \fn QChar::QChar(short code)
681
682 Constructs a QChar for the character with Unicode code point \a code.
683
684 \include qchar.cpp qchar-implicit-conversions
685*/
686
687/*!
688 \fn QChar::QChar(char32_t code)
689
690 Constructs a QChar for the character with Unicode code point \a code.
691
692 \include qchar.cpp qchar-implicit-conversions
693*/
694
695/*!
696 \fn QChar::QChar(uint code)
697
698 Constructs a QChar for the character with Unicode code point \a code.
699
700 \include qchar.cpp qchar-implicit-conversions
701*/
702
703/*!
704 \fn QChar::QChar(int code)
705
706 Constructs a QChar for the character with Unicode code point \a code.
707
708 \include qchar.cpp qchar-implicit-conversions
709*/
710
711/*!
712 \fn static QChar QChar::fromUcs2(char16_t c)
713 \since 6.0
714
715 Constructs a QChar from UTF-16 character \a c.
716
717 \sa fromUcs4()
718*/
719
720/*!
721 \fn static auto QChar::fromUcs4(char32_t c)
722 \since 6.0
723
724 Returns an anonymous struct that
725 \list
726 \li contains a \c{char16_t chars[2]} array,
727 \li can be implicitly converted to a QStringView, and
728 \li iterated over with a C++11 ranged for loop.
729 \endlist
730
731 If \a c requires surrogates, \c{chars[0]} contains the high surrogate
732 and \c{chars[1]} the low surrogate, and the QStringView has size 2.
733 Otherwise, \c{chars[0]} contains \a c and \c{chars[1]} is
734 \l{QChar::isNull}{null}, and the QStringView has size 1.
735
736 This allows easy use of the result:
737
738 \code
739 QString s;
740 s += QChar::fromUcs4(ch);
741 \endcode
742
743 \code
744 for (char16_t c16 : QChar::fromUcs4(ch))
745 use(c16);
746 \endcode
747
748 \sa fromUcs2(), requiresSurrogates()
749*/
750
751/*!
752 \fn bool QChar::isNull() const
753
754 Returns \c true if the character is the Unicode character 0x0000
755 ('\\0'); otherwise returns \c false.
756*/
757
758/*!
759 \fn uchar QChar::cell() const
760
761 Returns the cell (least significant byte) of the Unicode character.
762
763 \sa row()
764*/
765
766/*!
767 \fn uchar QChar::row() const
768
769 Returns the row (most significant byte) of the Unicode character.
770
771 \sa cell()
772*/
773
774/*!
775 \fn bool QChar::isPrint() const
776
777 Returns \c true if the character is a printable character; otherwise
778 returns \c false. This is any character not of category Other_*.
779
780 Note that this gives no indication of whether the character is
781 available in a particular font.
782*/
783
784/*!
785 \overload
786 \since 5.0
787
788 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
789 a printable character; otherwise returns \c false.
790 This is any character not of category Other_*.
791
792 Note that this gives no indication of whether the character is
793 available in a particular font.
794
795 \note Before Qt 6, this function took a \c uint argument.
796*/
797bool QChar::isPrint(char32_t ucs4) noexcept
798{
799 if (ucs4 > LastValidCodePoint)
800 return false;
801 const int test = FLAG(Other_Control) |
802 FLAG(Other_Format) |
803 FLAG(Other_Surrogate) |
804 FLAG(Other_PrivateUse) |
805 FLAG(Other_NotAssigned);
806 return !(FLAG(qGetProp(ucs4)->category) & test);
807}
808
809/*!
810 \fn bool QChar::isSpace() const
811
812 Returns \c true if the character is a separator character
813 (Separator_* categories or certain code points from Other_Control category);
814 otherwise returns \c false.
815*/
816
817/*!
818 \fn bool QChar::isSpace(char32_t ucs4)
819 \overload
820 \since 5.0
821
822 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
823 a separator character (Separator_* categories or certain code points
824 from Other_Control category); otherwise returns \c false.
825
826 \note Before Qt 6, this function took a \c uint argument.
827*/
828
829/*!
830 \internal
831*/
832bool QT_FASTCALL QChar::isSpace_helper(char32_t ucs4) noexcept
833{
834 if (ucs4 > MaxSeparatorCodepoint)
835 return false;
836
837 const int test = FLAG(Separator_Space) |
838 FLAG(Separator_Line) |
839 FLAG(Separator_Paragraph);
840 return FLAG(qGetProp(ucs4)->category) & test;
841}
842
843/*!
844 \fn bool QChar::isMark() const
845
846 Returns \c true if the character is a mark (Mark_* categories);
847 otherwise returns \c false.
848
849 See QChar::Category for more information regarding marks.
850*/
851
852/*!
853 \overload
854 \since 5.0
855
856 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
857 a mark (Mark_* categories); otherwise returns \c false.
858
859 \note Before Qt 6, this function took a \c uint argument.
860*/
861bool QChar::isMark(char32_t ucs4) noexcept
862{
863 if (ucs4 > LastValidCodePoint)
864 return false;
865 const int test = FLAG(Mark_NonSpacing) |
866 FLAG(Mark_SpacingCombining) |
867 FLAG(Mark_Enclosing);
868 return FLAG(qGetProp(ucs4)->category) & test;
869}
870
871/*!
872 \fn bool QChar::isPunct() const
873
874 Returns \c true if the character is a punctuation mark (Punctuation_*
875 categories); otherwise returns \c false.
876*/
877
878/*!
879 \overload
880 \since 5.0
881
882 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
883 a punctuation mark (Punctuation_* categories); otherwise returns \c false.
884
885 \note Before Qt 6, this function took a \c uint argument.
886*/
887bool QChar::isPunct(char32_t ucs4) noexcept
888{
889 if (ucs4 > LastValidCodePoint)
890 return false;
891 const int test = FLAG(Punctuation_Connector) |
892 FLAG(Punctuation_Dash) |
893 FLAG(Punctuation_Open) |
894 FLAG(Punctuation_Close) |
895 FLAG(Punctuation_InitialQuote) |
896 FLAG(Punctuation_FinalQuote) |
897 FLAG(Punctuation_Other);
898 return FLAG(qGetProp(ucs4)->category) & test;
899}
900
901/*!
902 \fn bool QChar::isSymbol() const
903
904 Returns \c true if the character is a symbol (Symbol_* categories);
905 otherwise returns \c false.
906*/
907
908/*!
909 \overload
910 \since 5.0
911
912 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
913 a symbol (Symbol_* categories); otherwise returns \c false.
914
915 \note Before Qt 6, this function took a \c uint argument.
916*/
917bool QChar::isSymbol(char32_t ucs4) noexcept
918{
919 if (ucs4 > LastValidCodePoint)
920 return false;
921 const int test = FLAG(Symbol_Math) |
922 FLAG(Symbol_Currency) |
923 FLAG(Symbol_Modifier) |
924 FLAG(Symbol_Other);
925 return FLAG(qGetProp(ucs4)->category) & test;
926}
927
928/*!
929 \fn bool QChar::isLetter() const
930
931 Returns \c true if the character is a letter (Letter_* categories);
932 otherwise returns \c false.
933*/
934
935/*!
936 \fn bool QChar::isLetter(char32_t ucs4)
937 \overload
938 \since 5.0
939
940 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
941 a letter (Letter_* categories); otherwise returns \c false.
942
943 \note Before Qt 6, this function took a \c uint argument.
944*/
945
946/*!
947 \internal
948*/
949bool QT_FASTCALL QChar::isLetter_helper(char32_t ucs4) noexcept
950{
951 if (ucs4 > LastValidCodePoint)
952 return false;
953 const int test = FLAG(Letter_Uppercase) |
954 FLAG(Letter_Lowercase) |
955 FLAG(Letter_Titlecase) |
956 FLAG(Letter_Modifier) |
957 FLAG(Letter_Other);
958 return FLAG(qGetProp(ucs4)->category) & test;
959}
960
961/*!
962 \fn bool QChar::isNumber() const
963
964 Returns \c true if the character is a number (Number_* categories,
965 not just 0-9); otherwise returns \c false.
966
967 \sa isDigit()
968*/
969
970/*!
971 \fn bool QChar::isNumber(char32_t ucs4)
972 \overload
973 \since 5.0
974
975 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
976 a number (Number_* categories, not just 0-9); otherwise returns \c false.
977
978 \note Before Qt 6, this function took a \c uint argument.
979
980 \sa isDigit()
981*/
982
983/*!
984 \internal
985*/
986bool QT_FASTCALL QChar::isNumber_helper(char32_t ucs4) noexcept
987{
988 if (ucs4 > LastValidCodePoint)
989 return false;
990 const int test = FLAG(Number_DecimalDigit) |
991 FLAG(Number_Letter) |
992 FLAG(Number_Other);
993 return FLAG(qGetProp(ucs4)->category) & test;
994}
995
996/*!
997 \fn bool QChar::isLetterOrNumber() const
998
999 Returns \c true if the character is a letter or number (Letter_* or
1000 Number_* categories); otherwise returns \c false.
1001*/
1002
1003/*!
1004 \fn bool QChar::isLetterOrNumber(char32_t ucs4)
1005 \overload
1006 \since 5.0
1007
1008 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
1009 a letter or number (Letter_* or Number_* categories); otherwise returns \c false.
1010
1011 \note Before Qt 6, this function took a \c uint argument.
1012*/
1013
1014/*!
1015 \internal
1016*/
1017bool QT_FASTCALL QChar::isLetterOrNumber_helper(char32_t ucs4) noexcept
1018{
1019 if (ucs4 > LastValidCodePoint)
1020 return false;
1021 const int test = FLAG(Letter_Uppercase) |
1022 FLAG(Letter_Lowercase) |
1023 FLAG(Letter_Titlecase) |
1024 FLAG(Letter_Modifier) |
1025 FLAG(Letter_Other) |
1026 FLAG(Number_DecimalDigit) |
1027 FLAG(Number_Letter) |
1028 FLAG(Number_Other);
1029 return FLAG(qGetProp(ucs4)->category) & test;
1030}
1031
1032/*!
1033 \fn bool QChar::isDigit() const
1034
1035 Returns \c true if the character is a decimal digit
1036 (Number_DecimalDigit); otherwise returns \c false.
1037
1038 \sa isNumber()
1039*/
1040
1041/*!
1042 \fn bool QChar::isDigit(char32_t ucs4)
1043 \overload
1044 \since 5.0
1045
1046 Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
1047 a decimal digit (Number_DecimalDigit); otherwise returns \c false.
1048
1049 \note Before Qt 6, this function took a \c uint argument.
1050
1051 \sa isNumber()
1052*/
1053
1054/*!
1055 \fn bool QChar::isNonCharacter() const
1056 \since 5.0
1057
1058 Returns \c true if the QChar is a non-character; false otherwise.
1059
1060 Unicode has a certain number of code points that are classified
1061 as "non-characters:" that is, they can be used for internal purposes
1062 in applications but cannot be used for text interchange.
1063 Those are the last two entries each Unicode Plane ([0xfffe..0xffff],
1064 [0x1fffe..0x1ffff], etc.) as well as the entries in range [0xfdd0..0xfdef].
1065*/
1066
1067/*!
1068 \fn bool QChar::isHighSurrogate() const
1069
1070 Returns \c true if the QChar is the high part of a UTF16 surrogate
1071 (for example if its code point is in range [0xd800..0xdbff]); false otherwise.
1072*/
1073
1074/*!
1075 \fn bool QChar::isLowSurrogate() const
1076
1077 Returns \c true if the QChar is the low part of a UTF16 surrogate
1078 (for example if its code point is in range [0xdc00..0xdfff]); false otherwise.
1079*/
1080
1081/*!
1082 \fn bool QChar::isSurrogate() const
1083 \since 5.0
1084
1085 Returns \c true if the QChar contains a code point that is in either
1086 the high or the low part of the UTF-16 surrogate range
1087 (for example if its code point is in range [0xd800..0xdfff]); false otherwise.
1088*/
1089
1090/*!
1091 \fn static bool QChar::isNonCharacter(char32_t ucs4)
1092 \overload
1093 \since 5.0
1094
1095 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1096 is a non-character; false otherwise.
1097
1098 Unicode has a certain number of code points that are classified
1099 as "non-characters:" that is, they can be used for internal purposes
1100 in applications but cannot be used for text interchange.
1101 Those are the last two entries each Unicode Plane ([0xfffe..0xffff],
1102 [0x1fffe..0x1ffff], etc.) as well as the entries in range [0xfdd0..0xfdef].
1103
1104 \note Before Qt 6, this function took a \c uint argument.
1105*/
1106
1107/*!
1108 \fn static bool QChar::isHighSurrogate(char32_t ucs4)
1109 \overload
1110
1111 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1112 is the high part of a UTF16 surrogate
1113 (for example if its code point is in range [0xd800..0xdbff]); false otherwise.
1114
1115 \note Before Qt 6, this function took a \c uint argument.
1116*/
1117
1118/*!
1119 \fn static bool QChar::isLowSurrogate(char32_t ucs4)
1120 \overload
1121
1122 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1123 is the low part of a UTF16 surrogate
1124 (for example if its code point is in range [0xdc00..0xdfff]); false otherwise.
1125
1126 \note Before Qt 6, this function took a \c uint argument.
1127*/
1128
1129/*!
1130 \fn static bool QChar::isSurrogate(char32_t ucs4)
1131 \overload
1132 \since 5.0
1133
1134 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1135 contains a code point that is in either the high or the low part of the
1136 UTF-16 surrogate range (for example if its code point is in range [0xd800..0xdfff]);
1137 false otherwise.
1138
1139 \note Before Qt 6, this function took a \c uint argument.
1140*/
1141
1142/*!
1143 \fn static bool QChar::requiresSurrogates(char32_t ucs4)
1144
1145 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1146 can be split into the high and low parts of a UTF16 surrogate
1147 (for example if its code point is greater than or equals to 0x10000);
1148 false otherwise.
1149
1150 \note Before Qt 6, this function took a \c uint argument.
1151*/
1152
1153/*!
1154 \fn static char32_t QChar::surrogateToUcs4(char16_t high, char16_t low)
1155
1156 Converts a UTF16 surrogate pair with the given \a high and \a low values
1157 to it's UCS-4-encoded code point.
1158
1159 \note Before Qt 6, this function took \c ushort arguments and returned \c uint.
1160*/
1161
1162/*!
1163 \fn static char32_t QChar::surrogateToUcs4(QChar high, QChar low)
1164 \overload
1165
1166 Converts a UTF16 surrogate pair (\a high, \a low) to it's UCS-4-encoded code point.
1167
1168 \note Before Qt 6, this function returned \c uint.
1169*/
1170
1171/*!
1172 \fn static char16_t QChar::highSurrogate(char32_t ucs4)
1173
1174 Returns the high surrogate part of a UCS-4-encoded code point.
1175 The returned result is undefined if \a ucs4 is smaller than 0x10000.
1176
1177 \note Before Qt 6, this function took a \c uint argument and returned \c ushort.
1178*/
1179
1180/*!
1181 \fn static char16_t QChar::lowSurrogate(char32_t ucs4)
1182
1183 Returns the low surrogate part of a UCS-4-encoded code point.
1184 The returned result is undefined if \a ucs4 is smaller than 0x10000.
1185
1186 \note Before Qt 6, this function took a \c uint argument and returned \c ushort.
1187*/
1188
1189/*!
1190 \fn int QChar::digitValue() const
1191
1192 Returns the numeric value of the digit, or -1 if the character is not a digit.
1193*/
1194
1195/*!
1196 \overload
1197 Returns the numeric value of the digit specified by the UCS-4-encoded
1198 character, \a ucs4, or -1 if the character is not a digit.
1199
1200 \note Before Qt 6, this function took a \c uint argument.
1201*/
1202int QChar::digitValue(char32_t ucs4) noexcept
1203{
1204 if (ucs4 > LastValidCodePoint)
1205 return -1;
1206 return qGetProp(ucs4)->digitValue;
1207}
1208
1209/*!
1210 \fn QChar::Category QChar::category() const
1211
1212 Returns the character's category.
1213*/
1214
1215/*!
1216 \overload
1217 Returns the category of the UCS-4-encoded character specified by \a ucs4.
1218
1219 \note Before Qt 6, this function took a \c uint argument.
1220*/
1221QChar::Category QChar::category(char32_t ucs4) noexcept
1222{
1223 if (ucs4 > LastValidCodePoint)
1224 return QChar::Other_NotAssigned;
1225 return (QChar::Category) qGetProp(ucs4)->category;
1226}
1227
1228/*!
1229 \fn QChar::Direction QChar::direction() const
1230
1231 Returns the character's direction.
1232*/
1233
1234/*!
1235 \overload
1236 Returns the direction of the UCS-4-encoded character specified by \a ucs4.
1237
1238 \note Before Qt 6, this function took a \c uint argument.
1239*/
1240QChar::Direction QChar::direction(char32_t ucs4) noexcept
1241{
1242 if (ucs4 > LastValidCodePoint)
1243 return QChar::DirL;
1244 return (QChar::Direction) qGetProp(ucs4)->direction;
1245}
1246
1247/*!
1248 \fn QChar::JoiningType QChar::joiningType() const
1249 \since 5.3
1250
1251 Returns information about the joining type attributes of the character
1252 (needed for certain languages such as Arabic or Syriac).
1253*/
1254
1255/*!
1256 \overload
1257 \since 5.3
1258
1259 Returns information about the joining type attributes of the UCS-4-encoded
1260 character specified by \a ucs4
1261 (needed for certain languages such as Arabic or Syriac).
1262
1263 \note Before Qt 6, this function took a \c uint argument.
1264*/
1265QChar::JoiningType QChar::joiningType(char32_t ucs4) noexcept
1266{
1267 if (ucs4 > LastValidCodePoint)
1268 return QChar::Joining_None;
1269 return QChar::JoiningType(qGetProp(ucs4)->joining);
1270}
1271
1272/*!
1273 \fn bool QChar::hasMirrored() const
1274
1275 Returns \c true if the character should be reversed if the text
1276 direction is reversed; otherwise returns \c false.
1277
1278 A bit faster equivalent of (ch.mirroredChar() != ch).
1279
1280 \sa mirroredChar()
1281*/
1282
1283/*!
1284 \overload
1285 \since 5.0
1286
1287 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1288 should be reversed if the text direction is reversed; otherwise returns \c false.
1289
1290 A bit faster equivalent of (QChar::mirroredChar(ucs4) != ucs4).
1291
1292 \note Before Qt 6, this function took a \c uint argument.
1293
1294 \sa mirroredChar()
1295*/
1296bool QChar::hasMirrored(char32_t ucs4) noexcept
1297{
1298 if (ucs4 > LastValidCodePoint)
1299 return false;
1300 return qGetProp(ucs4)->mirrorDiff != 0;
1301}
1302
1303/*!
1304 \fn bool QChar::isLower() const
1305
1306 Returns \c true if the character is a lowercase letter, for example
1307 category() is Letter_Lowercase.
1308
1309 \sa isUpper(), toLower(), toUpper()
1310*/
1311
1312/*!
1313 \fn static bool QChar::isLower(char32_t ucs4)
1314 \overload
1315 \since 5.0
1316
1317 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1318 is a lowercase letter, for example category() is Letter_Lowercase.
1319
1320 \note Before Qt 6, this function took a \c uint argument.
1321
1322 \sa isUpper(), toLower(), toUpper()
1323*/
1324
1325/*!
1326 \fn bool QChar::isUpper() const
1327
1328 Returns \c true if the character is an uppercase letter, for example
1329 category() is Letter_Uppercase.
1330
1331 \sa isLower(), toUpper(), toLower()
1332*/
1333
1334/*!
1335 \fn static bool QChar::isUpper(char32_t ucs4)
1336 \overload
1337 \since 5.0
1338
1339 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1340 is an uppercase letter, for example category() is Letter_Uppercase.
1341
1342 \note Before Qt 6, this function took a \c uint argument.
1343
1344 \sa isLower(), toUpper(), toLower()
1345*/
1346
1347/*!
1348 \fn bool QChar::isTitleCase() const
1349
1350 Returns \c true if the character is a titlecase letter, for example
1351 category() is Letter_Titlecase.
1352
1353 \sa isLower(), toUpper(), toLower(), toTitleCase()
1354*/
1355
1356/*!
1357 \fn static bool QChar::isTitleCase(char32_t ucs4)
1358 \overload
1359 \since 5.0
1360
1361 Returns \c true if the UCS-4-encoded character specified by \a ucs4
1362 is a titlecase letter, for example category() is Letter_Titlecase.
1363
1364 \note Before Qt 6, this function took a \c uint argument.
1365
1366 \sa isLower(), toUpper(), toLower(), toTitleCase()
1367*/
1368/*!
1369 \fn QChar QChar::mirroredChar() const
1370
1371 Returns the mirrored character if this character is a mirrored
1372 character; otherwise returns the character itself.
1373
1374 \sa hasMirrored()
1375*/
1376
1377/*!
1378 \overload
1379 Returns the mirrored character if the UCS-4-encoded character specified
1380 by \a ucs4 is a mirrored character; otherwise returns the character itself.
1381
1382 \note Before Qt 6, this function took a \c uint argument and returned \c uint.
1383
1384 \sa hasMirrored()
1385*/
1386char32_t QChar::mirroredChar(char32_t ucs4) noexcept
1387{
1388 if (ucs4 > LastValidCodePoint)
1389 return ucs4;
1390 return ucs4 + qGetProp(ucs4)->mirrorDiff;
1391}
1392
1393// Constants for Hangul (de)composition, see UAX #15:
1394static constexpr char32_t Hangul_SBase = 0xac00;
1395static constexpr char32_t Hangul_LBase = 0x1100;
1396static constexpr char32_t Hangul_VBase = 0x1161;
1397static constexpr char32_t Hangul_TBase = 0x11a7;
1398static constexpr quint32 Hangul_LCount = 19;
1399static constexpr quint32 Hangul_VCount = 21;
1400static constexpr quint32 Hangul_TCount = 28;
1401static constexpr quint32 Hangul_NCount = Hangul_VCount * Hangul_TCount;
1402static constexpr quint32 Hangul_SCount = Hangul_LCount * Hangul_NCount;
1403
1404// buffer has to have a length of 3. It's needed for Hangul decomposition
1405static const QChar * QT_FASTCALL decompositionHelper(
1406 char32_t ucs4, qsizetype *length, QChar::Decomposition *tag, QChar *buffer)
1407{
1408 if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) {
1409 // compute Hangul syllable decomposition as per UAX #15
1410 const char32_t SIndex = ucs4 - Hangul_SBase;
1411 buffer[0] = QChar(Hangul_LBase + SIndex / Hangul_NCount); // L
1412 buffer[1] = QChar(Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount); // V
1413 buffer[2] = QChar(Hangul_TBase + SIndex % Hangul_TCount); // T
1414 *length = buffer[2].unicode() == Hangul_TBase ? 2 : 3;
1415 *tag = QChar::Canonical;
1416 return buffer;
1417 }
1418
1419 const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1420 if (index == 0xffff) {
1421 *length = 0;
1422 *tag = QChar::NoDecomposition;
1423 return nullptr;
1424 }
1425
1426 const unsigned short *decomposition = uc_decomposition_map+index;
1427 *tag = QChar::Decomposition((*decomposition) & 0xff);
1428 *length = (*decomposition) >> 8;
1429 return reinterpret_cast<const QChar *>(decomposition + 1);
1430}
1431
1432/*!
1433 Decomposes a character into it's constituent parts. Returns an empty string
1434 if no decomposition exists.
1435*/
1436QString QChar::decomposition() const
1437{
1438 return QChar::decomposition(ucs);
1439}
1440
1441/*!
1442 \overload
1443 Decomposes the UCS-4-encoded character specified by \a ucs4 into it's
1444 constituent parts. Returns an empty string if no decomposition exists.
1445
1446 \note Before Qt 6, this function took a \c uint argument.
1447*/
1448QString QChar::decomposition(char32_t ucs4)
1449{
1450 QChar buffer[3];
1451 qsizetype length;
1452 QChar::Decomposition tag;
1453 const QChar *d = decompositionHelper(ucs4, &length, &tag, buffer);
1454 return QString(d, length);
1455}
1456
1457/*!
1458 \fn QChar::Decomposition QChar::decompositionTag() const
1459
1460 Returns the tag defining the composition of the character. Returns
1461 QChar::NoDecomposition if no decomposition exists.
1462*/
1463
1464/*!
1465 \overload
1466 Returns the tag defining the composition of the UCS-4-encoded character
1467 specified by \a ucs4. Returns QChar::NoDecomposition if no decomposition exists.
1468
1469 \note Before Qt 6, this function took a \c uint argument.
1470*/
1471QChar::Decomposition QChar::decompositionTag(char32_t ucs4) noexcept
1472{
1473 if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
1474 return QChar::Canonical;
1475 const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4);
1476 if (index == 0xffff)
1477 return QChar::NoDecomposition;
1478 return (QChar::Decomposition)(uc_decomposition_map[index] & 0xff);
1479}
1480
1481/*!
1482 \fn unsigned char QChar::combiningClass() const
1483
1484 Returns the combining class for the character as defined in the
1485 Unicode standard. This is mainly useful as a positioning hint for
1486 marks attached to a base character.
1487
1488 The Qt text rendering engine uses this information to correctly
1489 position non-spacing marks around a base character.
1490*/
1491
1492/*!
1493 \overload
1494 Returns the combining class for the UCS-4-encoded character specified by
1495 \a ucs4, as defined in the Unicode standard.
1496
1497 \note Before Qt 6, this function took a \c uint argument.
1498*/
1499unsigned char QChar::combiningClass(char32_t ucs4) noexcept
1500{
1501 if (ucs4 > LastValidCodePoint)
1502 return 0;
1503 return (unsigned char) qGetProp(ucs4)->combiningClass;
1504}
1505
1506/*!
1507 \fn QChar::Script QChar::script() const
1508 \since 5.1
1509
1510 Returns the Unicode script property value for this character.
1511*/
1512
1513/*!
1514 \overload
1515 \since 5.1
1516
1517 Returns the Unicode script property value for the character specified in
1518 its UCS-4-encoded form as \a ucs4.
1519
1520 \note Before Qt 6, this function took a \c uint argument.
1521*/
1522QChar::Script QChar::script(char32_t ucs4) noexcept
1523{
1524 if (ucs4 > LastValidCodePoint)
1525 return QChar::Script_Unknown;
1526 return (QChar::Script) qGetProp(ucs4)->script;
1527}
1528
1529/*!
1530 \fn QChar::UnicodeVersion QChar::unicodeVersion() const
1531
1532 Returns the Unicode version that introduced this character.
1533*/
1534
1535/*!
1536 \overload
1537 Returns the Unicode version that introduced the character specified in
1538 its UCS-4-encoded form as \a ucs4.
1539
1540 \note Before Qt 6, this function took a \c uint argument.
1541*/
1542QChar::UnicodeVersion QChar::unicodeVersion(char32_t ucs4) noexcept
1543{
1544 if (ucs4 > LastValidCodePoint)
1545 return QChar::Unicode_Unassigned;
1546 return (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion;
1547}
1548
1549/*!
1550 Returns the most recent supported Unicode version.
1551*/
1552QChar::UnicodeVersion QChar::currentUnicodeVersion() noexcept
1553{
1554 return UNICODE_DATA_VERSION;
1555}
1556
1557static auto fullConvertCase(char32_t uc, QUnicodeTables::Case which) noexcept
1558{
1559 struct R {
1560 char16_t chars[MaxSpecialCaseLength + 1];
1561 qint8 sz;
1562
1563 // iterable
1564 auto begin() const { return chars; }
1565 auto end() const { return chars + sz; }
1566 // QStringView-compatible
1567 auto data() const { return chars; }
1568 auto size() const { return sz; }
1569 } result;
1570 Q_ASSERT(uc <= QChar::LastValidCodePoint);
1571
1572 auto pp = result.chars;
1573
1574 const auto fold = caseConversion(uc)[which];
1575 const auto caseDiff = fold.diff;
1576
1577 if (Q_UNLIKELY(fold.special)) {
1578 const auto *specialCase = specialCaseMap + caseDiff;
1579 auto length = *specialCase++;
1580 while (length--)
1581 *pp++ = *specialCase++;
1582 } else {
1583 // so far, case conversion never changes planes (guaranteed by the qunicodetables generator)
1584 for (char16_t c : QChar::fromUcs4(uc + caseDiff))
1585 *pp++ = c;
1586 }
1587 result.sz = pp - result.chars;
1588 return result;
1589}
1590
1591template <typename T>
1592Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc, QUnicodeTables::Case which) noexcept
1593{
1594 const auto fold = caseConversion(uc)[which];
1595
1596 if (Q_UNLIKELY(fold.special)) {
1597 const ushort *specialCase = specialCaseMap + fold.diff;
1598 // so far, there are no special cases beyond BMP (guaranteed by the qunicodetables generator)
1599 return *specialCase == 1 ? specialCase[1] : uc;
1600 }
1601
1602 return uc + fold.diff;
1603}
1604
1605/*!
1606 \fn QChar QChar::toLower() const
1607
1608 Returns the lowercase equivalent if the character is uppercase or titlecase;
1609 otherwise returns the character itself.
1610*/
1611
1612/*!
1613 \overload
1614 Returns the lowercase equivalent of the UCS-4-encoded character specified
1615 by \a ucs4 if the character is uppercase or titlecase; otherwise returns
1616 the character itself.
1617
1618 \note Before Qt 6, this function took a \c uint argument and returned \c uint.
1619*/
1620char32_t QChar::toLower(char32_t ucs4) noexcept
1621{
1622 if (ucs4 > LastValidCodePoint)
1623 return ucs4;
1624 return convertCase_helper(ucs4, QUnicodeTables::LowerCase);
1625}
1626
1627/*!
1628 \fn QChar QChar::toUpper() const
1629
1630 Returns the uppercase equivalent if the character is lowercase or titlecase;
1631 otherwise returns the character itself.
1632
1633 \note This function also returns the original character in the rare case of
1634 the uppercase form of the character requiring two or more characters.
1635
1636 \sa QString::toUpper()
1637*/
1638
1639/*!
1640 \overload
1641 Returns the uppercase equivalent of the UCS-4-encoded character specified
1642 by \a ucs4 if the character is lowercase or titlecase; otherwise returns
1643 the character itself.
1644
1645 \note This function also returns the original character in the rare case of
1646 the uppercase form of the character requiring two or more characters.
1647
1648 \note Before Qt 6, this function took a \c uint argument and returned \c uint.
1649
1650 \sa QString::toUpper()
1651*/
1652char32_t QChar::toUpper(char32_t ucs4) noexcept
1653{
1654 if (ucs4 > LastValidCodePoint)
1655 return ucs4;
1656 return convertCase_helper(ucs4, QUnicodeTables::UpperCase);
1657}
1658
1659/*!
1660 \fn QChar QChar::toTitleCase() const
1661
1662 Returns the title case equivalent if the character is lowercase or uppercase;
1663 otherwise returns the character itself.
1664*/
1665
1666/*!
1667 \overload
1668 Returns the title case equivalent of the UCS-4-encoded character specified
1669 by \a ucs4 if the character is lowercase or uppercase; otherwise returns
1670 the character itself.
1671
1672 \note Before Qt 6, this function took a \c uint argument and returned \c uint.
1673*/
1674char32_t QChar::toTitleCase(char32_t ucs4) noexcept
1675{
1676 if (ucs4 > LastValidCodePoint)
1677 return ucs4;
1678 return convertCase_helper(ucs4, QUnicodeTables::TitleCase);
1679}
1680
1681static inline char32_t foldCase(const char16_t *ch, const char16_t *start)
1682{
1683 char32_t ucs4 = *ch;
1684 if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1)))
1685 ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4);
1686 return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
1687}
1688
1689static inline char32_t foldCase(char32_t ch, char32_t &last) noexcept
1690{
1691 char32_t ucs4 = ch;
1692 if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last))
1693 ucs4 = QChar::surrogateToUcs4(last, ucs4);
1694 last = ch;
1695 return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
1696}
1697
1698static inline char16_t foldCase(char16_t ch) noexcept
1699{
1700 return convertCase_helper(ch, QUnicodeTables::CaseFold);
1701}
1702
1703static inline QChar foldCase(QChar ch) noexcept
1704{
1705 return QChar(foldCase(ch.unicode()));
1706}
1707
1708/*!
1709 \fn QChar QChar::toCaseFolded() const
1710
1711 Returns the case folded equivalent of the character.
1712 For most Unicode characters this is the same as toLower().
1713*/
1714
1715/*!
1716 \overload
1717 Returns the case folded equivalent of the UCS-4-encoded character specified
1718 by \a ucs4. For most Unicode characters this is the same as toLower().
1719
1720 \note Before Qt 6, this function took a \c uint argument and returned \c uint.
1721*/
1722char32_t QChar::toCaseFolded(char32_t ucs4) noexcept
1723{
1724 if (ucs4 > LastValidCodePoint)
1725 return ucs4;
1726 return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
1727}
1728
1729/*!
1730 \fn char QChar::toLatin1() const
1731
1732 Returns the Latin-1 character equivalent to the QChar, or 0. This
1733 is mainly useful for non-internationalized software.
1734
1735 \note It is not possible to distinguish a non-Latin-1 character from a Latin-1 0
1736 (NUL) character. Prefer to use unicode(), which does not have this ambiguity.
1737
1738 \sa unicode()
1739*/
1740
1741/*!
1742 \fn QChar QChar::fromLatin1(char)
1743
1744 Converts the Latin-1 character \a c to its equivalent QChar. This
1745 is mainly useful for non-internationalized software.
1746
1747 An alternative is to use QLatin1Char.
1748
1749 \sa toLatin1(), unicode()
1750*/
1751
1752/*!
1753 \fn QChar::unicode()
1754
1755 Returns a reference to the numeric Unicode value of the QChar.
1756*/
1757
1758/*!
1759 \fn QChar::unicode() const
1760
1761 Returns the numeric Unicode value of the QChar.
1762*/
1763
1764/*****************************************************************************
1765 Documentation of QChar related functions
1766 *****************************************************************************/
1767
1768/*!
1769 \fn bool QChar::operator==(const QChar &c1, const QChar &c2)
1770
1771 Returns \c true if \a c1 and \a c2 are the same Unicode character;
1772 otherwise returns \c false.
1773*/
1774
1775/*!
1776 \fn bool QChar::operator!=(const QChar &c1, const QChar &c2)
1777
1778 Returns \c true if \a c1 and \a c2 are not the same Unicode
1779 character; otherwise returns \c false.
1780*/
1781
1782/*!
1783 \fn bool QChar::operator<=(const QChar &c1, const QChar &c2)
1784
1785 Returns \c true if the numeric Unicode value of \a c1 is less than
1786 or equal to that of \a c2; otherwise returns \c false.
1787*/
1788
1789/*!
1790 \fn bool QChar::operator>=(const QChar &c1, const QChar &c2)
1791
1792 Returns \c true if the numeric Unicode value of \a c1 is greater than
1793 or equal to that of \a c2; otherwise returns \c false.
1794*/
1795
1796/*!
1797 \fn bool QChar::operator<(const QChar &c1, const QChar &c2)
1798
1799 Returns \c true if the numeric Unicode value of \a c1 is less than
1800 that of \a c2; otherwise returns \c false.
1801*/
1802
1803/*!
1804 \fn bool QChar::operator>(const QChar &c1, const QChar &c2)
1805
1806 Returns \c true if the numeric Unicode value of \a c1 is greater than
1807 that of \a c2; otherwise returns \c false.
1808*/
1809
1810/*!
1811 \fn Qt::Literals::StringLiterals::operator""_L1(char ch)
1812
1813 \relates QLatin1Char
1814 \since 6.4
1815
1816 Literal operator that creates a QLatin1Char out of \a ch.
1817
1818 The following code creates a QLatin1Char:
1819 \code
1820 using namespace Qt::StringLiterals;
1821
1822 auto ch = 'a'_L1;
1823 \endcode
1824
1825 \sa Qt::Literals::StringLiterals
1826*/
1827
1828// ---------------------------------------------------------------------------
1829
1830
1831static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, qsizetype from)
1832{
1833 qsizetype length;
1834 QChar::Decomposition tag;
1835 QChar buffer[3];
1836
1837 QString &s = *str;
1838
1839 const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data());
1840 const unsigned short *uc = utf16 + s.size();
1841 while (uc != utf16 + from) {
1842 char32_t ucs4 = *(--uc);
1843 if (QChar(ucs4).isLowSurrogate() && uc != utf16) {
1844 ushort high = *(uc - 1);
1845 if (QChar(high).isHighSurrogate()) {
1846 --uc;
1847 ucs4 = QChar::surrogateToUcs4(high, ucs4);
1848 }
1849 }
1850
1851 if (QChar::unicodeVersion(ucs4) > version)
1852 continue;
1853
1854 const QChar *d = decompositionHelper(ucs4, &length, &tag, buffer);
1855 if (!d || (canonical && tag != QChar::Canonical))
1856 continue;
1857
1858 qsizetype pos = uc - utf16;
1859 s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, d, length);
1860 // since the replace invalidates the pointers and we do decomposition recursive
1861 utf16 = reinterpret_cast<unsigned short *>(s.data());
1862 uc = utf16 + pos + length;
1863 }
1864}
1865
1866
1867struct UCS2Pair {
1868 ushort u1;
1869 ushort u2;
1870};
1871
1872inline bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2)
1873{ return ligature1.u1 < ligature2.u1; }
1874inline bool operator<(ushort u1, const UCS2Pair &ligature)
1875{ return u1 < ligature.u1; }
1876inline bool operator<(const UCS2Pair &ligature, ushort u1)
1877{ return ligature.u1 < u1; }
1878
1883
1884inline bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2)
1885{ return QChar::surrogateToUcs4(ligature1.p1.u1, ligature1.p1.u2) < QChar::surrogateToUcs4(ligature2.p1.u1, ligature2.p1.u2); }
1886inline bool operator<(char32_t u1, const UCS2SurrogatePair &ligature)
1887{ return u1 < QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2); }
1888inline bool operator<(const UCS2SurrogatePair &ligature, char32_t u1)
1889{ return QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2) < u1; }
1890
1891static char32_t inline ligatureHelper(char32_t u1, char32_t u2)
1892{
1893 if (u1 >= Hangul_LBase && u1 < Hangul_SBase + Hangul_SCount) {
1894 // compute Hangul syllable composition as per UAX #15
1895 // hangul L-V pair
1896 const char32_t LIndex = u1 - Hangul_LBase;
1897 if (LIndex < Hangul_LCount) {
1898 const char32_t VIndex = u2 - Hangul_VBase;
1899 if (VIndex < Hangul_VCount)
1900 return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount;
1901 }
1902 // hangul LV-T pair
1903 const char32_t SIndex = u1 - Hangul_SBase;
1904 if (SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) {
1905 const char32_t TIndex = u2 - Hangul_TBase;
1906 if (TIndex < Hangul_TCount && TIndex)
1907 return u1 + TIndex;
1908 }
1909 }
1910
1911 const unsigned short index = GET_LIGATURE_INDEX(u2);
1912 if (index == 0xffff)
1913 return 0;
1914 const unsigned short *ligatures = uc_ligature_map+index;
1915 ushort length = *ligatures++;
1916 if (QChar::requiresSurrogates(u1)) {
1917 const UCS2SurrogatePair *data = reinterpret_cast<const UCS2SurrogatePair *>(ligatures);
1918 const UCS2SurrogatePair *r = std::lower_bound(data, data + length, u1);
1919 if (r != data + length && QChar::surrogateToUcs4(r->p1.u1, r->p1.u2) == u1)
1920 return QChar::surrogateToUcs4(r->p2.u1, r->p2.u2);
1921 } else {
1922 const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures);
1923 const UCS2Pair *r = std::lower_bound(data, data + length, ushort(u1));
1924 if (r != data + length && r->u1 == ushort(u1))
1925 return r->u2;
1926 }
1927
1928 return 0;
1929}
1930
1931static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
1932{
1933 QString &s = *str;
1934
1935 if (from < 0 || s.size() - from < 2)
1936 return;
1937
1938 char32_t stcode = 0; // starter code point
1939 qsizetype starter = -1; // starter position
1940 qsizetype next = -1; // to prevent i == next
1941 int lastCombining = 255; // to prevent combining > lastCombining
1942
1943 qsizetype pos = from;
1944 while (pos < s.size()) {
1945 qsizetype i = pos;
1946 char32_t uc = s.at(pos).unicode();
1947 if (QChar(uc).isHighSurrogate() && pos < s.size()-1) {
1948 ushort low = s.at(pos+1).unicode();
1949 if (QChar(low).isLowSurrogate()) {
1950 uc = QChar::surrogateToUcs4(uc, low);
1951 ++pos;
1952 }
1953 }
1954
1955 const QUnicodeTables::Properties *p = qGetProp(uc);
1956 if (p->unicodeVersion > version) {
1957 starter = -1;
1958 next = -1; // to prevent i == next
1959 lastCombining = 255; // to prevent combining > lastCombining
1960 ++pos;
1961 continue;
1962 }
1963
1964 int combining = p->combiningClass;
1965 if ((i == next || combining > lastCombining) && starter >= from) {
1966 // allowed to form ligature with S
1967 char32_t ligature = ligatureHelper(stcode, uc);
1968 if (ligature) {
1969 stcode = ligature;
1970 QChar *d = s.data();
1971 // ligatureHelper() never changes planes
1972 qsizetype j = 0;
1973 for (QChar ch : QChar::fromUcs4(ligature))
1974 d[starter + j++] = ch;
1975 s.remove(i, j);
1976 continue;
1977 }
1978 }
1979 if (combining == 0) {
1980 starter = i;
1981 stcode = uc;
1982 next = pos + 1;
1983 }
1984 lastCombining = combining;
1985
1986 ++pos;
1987 }
1988}
1989
1990
1991static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
1992{
1993 QString &s = *str;
1994 const qsizetype l = s.size()-1;
1995
1996 char32_t u1, u2;
1997 char16_t c1, c2;
1998
1999 qsizetype pos = from;
2000 while (pos < l) {
2001 qsizetype p2 = pos+1;
2002 u1 = s.at(pos).unicode();
2003 if (QChar::isHighSurrogate(u1)) {
2004 const char16_t low = s.at(p2).unicode();
2005 if (QChar::isLowSurrogate(low)) {
2006 u1 = QChar::surrogateToUcs4(u1, low);
2007 if (p2 >= l)
2008 break;
2009 ++p2;
2010 }
2011 }
2012 c1 = 0;
2013
2014 advance:
2015 u2 = s.at(p2).unicode();
2016 if (QChar::isHighSurrogate(u2) && p2 < l) {
2017 const char16_t low = s.at(p2+1).unicode();
2018 if (QChar::isLowSurrogate(low)) {
2019 u2 = QChar::surrogateToUcs4(u2, low);
2020 ++p2;
2021 }
2022 }
2023
2024 c2 = 0;
2025 {
2026 const QUnicodeTables::Properties *p = qGetProp(u2);
2027 if (p->unicodeVersion <= version)
2028 c2 = p->combiningClass;
2029 }
2030 if (c2 == 0) {
2031 pos = p2+1;
2032 continue;
2033 }
2034
2035 if (c1 == 0) {
2036 const QUnicodeTables::Properties *p = qGetProp(u1);
2037 if (p->unicodeVersion <= version)
2038 c1 = p->combiningClass;
2039 }
2040
2041 if (c1 > c2) {
2042 QChar *uc = s.data();
2043 qsizetype p = pos;
2044 // exchange characters
2045 for (QChar ch : QChar::fromUcs4(u2))
2046 uc[p++] = ch;
2047 for (QChar ch : QChar::fromUcs4(u1))
2048 uc[p++] = ch;
2049 if (pos > 0)
2050 --pos;
2051 if (pos > 0 && s.at(pos).isLowSurrogate())
2052 --pos;
2053 } else {
2054 ++pos;
2055 if (QChar::requiresSurrogates(u1))
2056 ++pos;
2057
2058 u1 = u2;
2059 c1 = c2; // != 0
2060 p2 = pos + 1;
2061 if (QChar::requiresSurrogates(u1))
2062 ++p2;
2063 if (p2 > l)
2064 break;
2065
2066 goto advance;
2067 }
2068 }
2069}
2070
2071// returns true if the text is in a desired Normalization Form already; false otherwise.
2072// sets lastStable to the position of the last stable code point
2073static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, qsizetype from, qsizetype *lastStable)
2074{
2075 static_assert(QString::NormalizationForm_D == 0);
2076 static_assert(QString::NormalizationForm_C == 1);
2077 static_assert(QString::NormalizationForm_KD == 2);
2078 static_assert(QString::NormalizationForm_KC == 3);
2079
2080 enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
2081
2082 const auto *string = reinterpret_cast<const char16_t *>(str->constData());
2083 qsizetype length = str->size();
2084
2085 // this avoids one out of bounds check in the loop
2086 while (length > from && QChar::isHighSurrogate(string[length - 1]))
2087 --length;
2088
2089 uchar lastCombining = 0;
2090 for (qsizetype i = from; i < length; ++i) {
2091 qsizetype pos = i;
2092 char32_t uc = string[i];
2093 if (uc < 0x80) {
2094 // ASCII characters are stable code points
2095 lastCombining = 0;
2096 *lastStable = pos;
2097 continue;
2098 }
2099
2100 if (QChar::isHighSurrogate(uc)) {
2101 ushort low = string[i + 1];
2102 if (!QChar::isLowSurrogate(low)) {
2103 // treat surrogate like stable code point
2104 lastCombining = 0;
2105 *lastStable = pos;
2106 continue;
2107 }
2108 ++i;
2109 uc = QChar::surrogateToUcs4(uc, low);
2110 }
2111
2112 const QUnicodeTables::Properties *p = qGetProp(uc);
2113
2114 if (p->combiningClass < lastCombining && p->combiningClass > 0)
2115 return false;
2116
2117 const uchar check = (p->nfQuickCheck >> (mode << 1)) & 0x03;
2118 if (check != NFQC_YES)
2119 return false; // ### can we quick check NFQC_MAYBE ?
2120
2121 lastCombining = p->combiningClass;
2122 if (lastCombining == 0)
2123 *lastStable = pos;
2124 }
2125
2126 if (length != str->size()) // low surrogate parts at the end of text
2127 *lastStable = str->size() - 1;
2128
2129 return true;
2130}
2131
2132QT_END_NAMESPACE
static constexpr unsigned short specialCaseMap[]
constexpr unsigned int MaxSpecialCaseLength
static constexpr unsigned short uc_ligature_map[]
static Q_DECL_CONST_FUNCTION Q_ALWAYS_INLINE const Properties * qGetProp(char32_t ucs4) noexcept
bool operator<(const UCS2SurrogatePair &ligature, char32_t u1)
Definition qchar.cpp:1888
static constexpr quint32 Hangul_VCount
Definition qchar.cpp:1399
static constexpr char32_t Hangul_SBase
Definition qchar.cpp:1394
static constexpr char32_t Hangul_VBase
Definition qchar.cpp:1396
bool operator<(ushort u1, const UCS2Pair &ligature)
Definition qchar.cpp:1874
#define FLAG(x)
Definition qchar.cpp:14
static constexpr quint32 Hangul_LCount
Definition qchar.cpp:1398
static char32_t ligatureHelper(char32_t u1, char32_t u2)
Definition qchar.cpp:1891
bool operator<(const UCS2Pair &ligature, ushort u1)
Definition qchar.cpp:1876
static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1991
static constexpr char32_t Hangul_LBase
Definition qchar.cpp:1395
static constexpr char32_t Hangul_TBase
Definition qchar.cpp:1397
bool operator<(char32_t u1, const UCS2SurrogatePair &ligature)
Definition qchar.cpp:1886
static char32_t foldCase(char32_t ch, char32_t &last) noexcept
Definition qchar.cpp:1689
bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2)
Definition qchar.cpp:1884
bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2)
Definition qchar.cpp:1872
static auto fullConvertCase(char32_t uc, QUnicodeTables::Case which) noexcept
Definition qchar.cpp:1557
static constexpr quint32 Hangul_NCount
Definition qchar.cpp:1401
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1831
static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
Definition qchar.cpp:1931
static constexpr quint32 Hangul_SCount
Definition qchar.cpp:1402
static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, qsizetype from, qsizetype *lastStable)
Definition qchar.cpp:2073
static QChar foldCase(QChar ch) noexcept
Definition qchar.cpp:1703
static constexpr quint32 Hangul_TCount
Definition qchar.cpp:1400
static char16_t foldCase(char16_t ch) noexcept
Definition qchar.cpp:1698
static char32_t foldCase(const char16_t *ch, const char16_t *start)
Definition qchar.cpp:1681
uint QT_FASTCALL fetch1Pixel< QPixelLayout::BPP1LSB >(const uchar *src, int index)
#define GET_LIGATURE_INDEX(ucs4)
#define GET_DECOMPOSITION_INDEX(ucs4)
#define UNICODE_DATA_VERSION
ushort u1
Definition qchar.cpp:1868
ushort u2
Definition qchar.cpp:1869