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