2015-12-10 05:06:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
2019-06-03 14:21:30 +00:00
|
|
|
** Copyright (C) 2016-2019 Ivailo Monev
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
2019-07-02 18:13:44 +00:00
|
|
|
** This file is part of the QtCore module of the Katie Toolkit.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-10-30 02:50:48 +00:00
|
|
|
// Don't define it while compiling this module, or USERS of Qt will
|
|
|
|
// not be able to link.
|
|
|
|
#ifdef QT_NO_CAST_FROM_ASCII
|
|
|
|
# undef QT_NO_CAST_FROM_ASCII
|
|
|
|
#endif
|
|
|
|
#ifdef QT_NO_CAST_TO_ASCII
|
|
|
|
# undef QT_NO_CAST_TO_ASCII
|
|
|
|
#endif
|
2015-12-10 05:06:13 +02:00
|
|
|
#include "qchar.h"
|
|
|
|
#include "qdatastream.h"
|
|
|
|
#include "qtextcodec.h"
|
2019-07-23 20:02:45 +00:00
|
|
|
|
2019-11-21 18:18:37 +00:00
|
|
|
#include <unicode/uchar.h>
|
|
|
|
#include <unicode/unorm2.h>
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
#ifndef QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
# ifdef QT_NO_TEXTCODEC
|
|
|
|
# define QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2019-07-23 20:02:45 +00:00
|
|
|
static inline bool is_ascii_char(uint ucs4)
|
|
|
|
{
|
|
|
|
return ucs4 <= 127;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_ascii_number(uint ucs4)
|
|
|
|
{
|
|
|
|
return (ucs4 >= '0' && ucs4 <= '9');
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_ascii_lower(uint ucs4)
|
|
|
|
{
|
|
|
|
return (ucs4 >= 'a' && ucs4 <= 'z');
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_ascii_upper(uint ucs4)
|
|
|
|
{
|
|
|
|
return (ucs4 >= 'A' && ucs4 <= 'Z');
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_ascii_letterornumber(uint ucs4)
|
|
|
|
{
|
|
|
|
return (ucs4 >= 'a' && ucs4 <= 'z') || (ucs4 >= 'A' && ucs4 <= 'Z') || (ucs4 >= '0' && ucs4 <= '9');
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint to_ascii_lower(uint ucs4)
|
|
|
|
{
|
|
|
|
switch (ucs4) {
|
|
|
|
case 'A':
|
|
|
|
case 'B':
|
|
|
|
case 'C':
|
|
|
|
case 'D':
|
|
|
|
case 'E':
|
|
|
|
case 'F':
|
|
|
|
case 'G':
|
|
|
|
case 'H':
|
|
|
|
case 'I':
|
|
|
|
case 'J':
|
|
|
|
case 'K':
|
|
|
|
case 'L':
|
|
|
|
case 'M':
|
|
|
|
case 'N':
|
|
|
|
case 'O':
|
|
|
|
case 'P':
|
|
|
|
case 'Q':
|
|
|
|
case 'R':
|
|
|
|
case 'S':
|
|
|
|
case 'T':
|
|
|
|
case 'U':
|
|
|
|
case 'V':
|
|
|
|
case 'W':
|
|
|
|
case 'X':
|
|
|
|
case 'Y':
|
|
|
|
case 'Z':
|
|
|
|
return ucs4 + 32;
|
|
|
|
default:
|
|
|
|
return ucs4;
|
|
|
|
}
|
|
|
|
return ucs4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint to_ascii_upper(uint ucs4)
|
|
|
|
{
|
|
|
|
switch (ucs4) {
|
|
|
|
case 'a':
|
|
|
|
case 'b':
|
|
|
|
case 'c':
|
|
|
|
case 'd':
|
|
|
|
case 'e':
|
|
|
|
case 'f':
|
|
|
|
case 'g':
|
|
|
|
case 'h':
|
|
|
|
case 'i':
|
|
|
|
case 'j':
|
|
|
|
case 'k':
|
|
|
|
case 'l':
|
|
|
|
case 'm':
|
|
|
|
case 'n':
|
|
|
|
case 'o':
|
|
|
|
case 'p':
|
|
|
|
case 'q':
|
|
|
|
case 'r':
|
|
|
|
case 's':
|
|
|
|
case 't':
|
|
|
|
case 'u':
|
|
|
|
case 'v':
|
|
|
|
case 'w':
|
|
|
|
case 'x':
|
|
|
|
case 'y':
|
|
|
|
case 'z':
|
|
|
|
return ucs4 - 32;
|
|
|
|
default:
|
|
|
|
return ucs4;
|
|
|
|
}
|
|
|
|
return ucs4;
|
|
|
|
}
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\class QLatin1Char
|
|
|
|
\brief The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
|
|
|
|
|
|
|
|
\ingroup string-processing
|
|
|
|
|
|
|
|
This class is only useful to avoid the codec for C strings business
|
|
|
|
in the QChar(ch) constructor. You can avoid it by writing
|
|
|
|
QChar(ch, 0).
|
|
|
|
|
|
|
|
\sa QChar, QLatin1String, QString
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn const char QLatin1Char::toLatin1() const
|
|
|
|
|
|
|
|
Converts a Latin-1 character to an 8-bit ASCII representation of
|
|
|
|
the character.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn const ushort QLatin1Char::unicode() const
|
|
|
|
|
|
|
|
Converts a Latin-1 character to an 16-bit-encoded Unicode representation
|
|
|
|
of the character.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QLatin1Char::QLatin1Char(char c)
|
|
|
|
|
|
|
|
Constructs a Latin-1 character for \a c. This constructor should be
|
|
|
|
used when the encoding of the input character is known to be Latin-1.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class QChar
|
|
|
|
\brief The QChar class provides a 16-bit Unicode character.
|
|
|
|
|
|
|
|
\ingroup string-processing
|
|
|
|
\reentrant
|
|
|
|
|
|
|
|
In Qt, Unicode characters are 16-bit entities without any markup
|
|
|
|
or structure. This class represents such an entity. It is
|
|
|
|
lightweight, so it can be used everywhere. Most compilers treat
|
|
|
|
it like a \c{unsigned short}.
|
|
|
|
|
|
|
|
QChar provides a full complement of testing/classification
|
|
|
|
functions, converting to and from other formats, converting from
|
|
|
|
composed to decomposed Unicode, and trying to compare and
|
|
|
|
case-convert if you ask it to.
|
|
|
|
|
|
|
|
The classification functions include functions like those in the
|
|
|
|
standard C++ header \<cctype\> (formerly \<ctype.h\>), but
|
|
|
|
operating on the full range of Unicode characters. They all
|
|
|
|
return true if the character is a certain type of character;
|
|
|
|
otherwise they return false. These classification functions are
|
|
|
|
isNull() (returns true if the character is '\\0'), isPrint()
|
|
|
|
(true if the character is any sort of printable character,
|
|
|
|
including whitespace), isPunct() (any sort of punctation),
|
|
|
|
isMark() (Unicode Mark), isLetter() (a letter), isNumber() (any
|
|
|
|
sort of numeric character, not just 0-9), isLetterOrNumber(), and
|
|
|
|
isDigit() (decimal digits). All of these are wrappers around
|
|
|
|
category() which return the Unicode-defined category of each
|
|
|
|
character.
|
|
|
|
|
|
|
|
QChar also provides direction(), which indicates the "natural"
|
|
|
|
writing direction of this character. The joining() function
|
|
|
|
indicates how the character joins with its neighbors (needed
|
|
|
|
mostly for Arabic) and finally hasMirrored(), which indicates
|
|
|
|
whether the character needs to be mirrored when it is printed in
|
|
|
|
its "unnatural" writing direction.
|
|
|
|
|
|
|
|
Composed Unicode characters (like \aring) can be converted to
|
|
|
|
decomposed Unicode ("a" followed by "ring above") by using
|
|
|
|
decomposition().
|
|
|
|
|
|
|
|
In Unicode, comparison is not necessarily possible and case
|
|
|
|
conversion is very difficult at best. Unicode, covering the
|
|
|
|
"entire" world, also includes most of the world's case and
|
|
|
|
sorting problems. operator==() and friends will do comparison
|
|
|
|
based purely on the numeric Unicode value (code point) of the
|
|
|
|
characters, and toUpper() and toLower() will do case changes when
|
|
|
|
the character has a well-defined uppercase/lowercase equivalent.
|
|
|
|
For locale-dependent comparisons, use
|
|
|
|
QString::localeAwareCompare().
|
|
|
|
|
|
|
|
The conversion functions include unicode() (to a scalar),
|
|
|
|
toLatin1() (to scalar, but converts all non-Latin-1 characters to
|
|
|
|
0), row() (gives the Unicode row), cell() (gives the Unicode
|
|
|
|
cell), digitValue() (gives the integer value of any of the
|
|
|
|
numerous digit characters), and a host of constructors.
|
|
|
|
|
2016-10-30 02:50:48 +00:00
|
|
|
QChar provides constructors and cast operators that make it easy
|
|
|
|
to convert to and from traditional 8-bit \c{char}s. If you
|
|
|
|
defined \c QT_NO_CAST_FROM_ASCII and \c QT_NO_CAST_TO_ASCII, as
|
|
|
|
explained in the QString documentation, you will need to
|
|
|
|
explicitly call fromAscii() or fromLatin1(), or use QLatin1Char,
|
|
|
|
to construct a QChar from an 8-bit \c char, and you will need to
|
|
|
|
call toAscii() or toLatin1() to get the 8-bit value back.
|
|
|
|
|
2015-12-10 05:06:13 +02:00
|
|
|
\sa QString, Unicode, QLatin1Char
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::UnicodeVersion
|
|
|
|
|
|
|
|
Specifies which version of the \l{http://www.unicode.org/}{Unicode standard}
|
|
|
|
introduced a certain character.
|
|
|
|
|
2019-07-23 20:02:45 +00:00
|
|
|
\value Unicode_1_1
|
|
|
|
\value Unicode_2_0
|
|
|
|
\value Unicode_2_1
|
|
|
|
\value Unicode_3_0
|
|
|
|
\value Unicode_3_1
|
|
|
|
\value Unicode_3_2
|
|
|
|
\value Unicode_4_0
|
|
|
|
\value Unicode_4_1
|
|
|
|
\value Unicode_5_0
|
|
|
|
\value Unicode_5_1
|
|
|
|
\value Unicode_5_2
|
|
|
|
\value Unicode_6_0
|
|
|
|
\value Unicode_6_1
|
|
|
|
\value Unicode_6_2
|
|
|
|
\value Unicode_6_3
|
|
|
|
\value Unicode_7_0
|
|
|
|
\value Unicode_8_0
|
|
|
|
\value Unicode_9_0
|
|
|
|
\value Unicode_10_0
|
|
|
|
\value Unicode_11_0
|
|
|
|
\value Unicode_12_0
|
|
|
|
\value Unicode_12_1
|
|
|
|
\value Unicode_Last Latest supported version
|
2015-12-10 05:06:13 +02:00
|
|
|
\value Unicode_Unassigned The value is not assigned to any character
|
2019-07-23 20:02:45 +00:00
|
|
|
in Unicode.
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa unicodeVersion()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::Category
|
|
|
|
|
|
|
|
This enum maps the Unicode character categories.
|
|
|
|
|
|
|
|
The following characters are normative in Unicode:
|
|
|
|
|
|
|
|
\value Mark_NonSpacing Unicode class name Mn
|
|
|
|
|
|
|
|
\value Mark_SpacingCombining Unicode class name Mc
|
|
|
|
|
|
|
|
\value Mark_Enclosing Unicode class name Me
|
|
|
|
|
|
|
|
\value Number_DecimalDigit Unicode class name Nd
|
|
|
|
|
|
|
|
\value Number_Letter Unicode class name Nl
|
|
|
|
|
|
|
|
\value Number_Other Unicode class name No
|
|
|
|
|
|
|
|
\value Separator_Space Unicode class name Zs
|
|
|
|
|
|
|
|
\value Separator_Line Unicode class name Zl
|
|
|
|
|
|
|
|
\value Separator_Paragraph Unicode class name Zp
|
|
|
|
|
|
|
|
\value Other_Control Unicode class name Cc
|
|
|
|
|
|
|
|
\value Other_Format Unicode class name Cf
|
|
|
|
|
|
|
|
\value Other_Surrogate Unicode class name Cs
|
|
|
|
|
|
|
|
\value Other_PrivateUse Unicode class name Co
|
|
|
|
|
|
|
|
\value Other_NotAssigned Unicode class name Cn
|
|
|
|
|
|
|
|
|
|
|
|
The following categories are informative in Unicode:
|
|
|
|
|
|
|
|
\value Letter_Uppercase Unicode class name Lu
|
|
|
|
|
|
|
|
\value Letter_Lowercase Unicode class name Ll
|
|
|
|
|
|
|
|
\value Letter_Titlecase Unicode class name Lt
|
|
|
|
|
|
|
|
\value Letter_Modifier Unicode class name Lm
|
|
|
|
|
|
|
|
\value Letter_Other Unicode class name Lo
|
|
|
|
|
|
|
|
\value Punctuation_Connector Unicode class name Pc
|
|
|
|
|
|
|
|
\value Punctuation_Dash Unicode class name Pd
|
|
|
|
|
|
|
|
\value Punctuation_Open Unicode class name Ps
|
|
|
|
|
|
|
|
\value Punctuation_Close Unicode class name Pe
|
|
|
|
|
|
|
|
\value Punctuation_InitialQuote Unicode class name Pi
|
|
|
|
|
|
|
|
\value Punctuation_FinalQuote Unicode class name Pf
|
|
|
|
|
|
|
|
\value Punctuation_Other Unicode class name Po
|
|
|
|
|
|
|
|
\value Symbol_Math Unicode class name Sm
|
|
|
|
|
|
|
|
\value Symbol_Currency Unicode class name Sc
|
|
|
|
|
|
|
|
\value Symbol_Modifier Unicode class name Sk
|
|
|
|
|
|
|
|
\value Symbol_Other Unicode class name So
|
|
|
|
|
|
|
|
\sa category()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::Direction
|
|
|
|
|
|
|
|
This enum type defines the Unicode direction attributes. See the
|
|
|
|
\l{http://www.unicode.org/}{Unicode Standard} for a description
|
|
|
|
of the values.
|
|
|
|
|
|
|
|
In order to conform to C/C++ naming conventions "Dir" is prepended
|
|
|
|
to the codes used in the Unicode Standard.
|
|
|
|
|
|
|
|
\value DirAL
|
|
|
|
\value DirAN
|
|
|
|
\value DirB
|
|
|
|
\value DirBN
|
|
|
|
\value DirCS
|
|
|
|
\value DirEN
|
|
|
|
\value DirES
|
|
|
|
\value DirET
|
|
|
|
\value DirL
|
|
|
|
\value DirLRE
|
|
|
|
\value DirLRO
|
|
|
|
\value DirNSM
|
|
|
|
\value DirON
|
|
|
|
\value DirPDF
|
|
|
|
\value DirR
|
|
|
|
\value DirRLE
|
|
|
|
\value DirRLO
|
|
|
|
\value DirS
|
|
|
|
\value DirWS
|
2019-07-23 20:02:45 +00:00
|
|
|
\value DirLRI
|
|
|
|
\value DirRLI
|
|
|
|
\value DirFSI
|
|
|
|
\value DirPDI
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa direction()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::Decomposition
|
|
|
|
|
|
|
|
This enum type defines the Unicode decomposition attributes. See
|
|
|
|
the \l{http://www.unicode.org/}{Unicode Standard} for a
|
|
|
|
description of the values.
|
|
|
|
|
|
|
|
\value NoDecomposition
|
2019-11-21 18:18:37 +00:00
|
|
|
\value Canonical
|
2015-12-10 05:06:13 +02:00
|
|
|
\value Font
|
2019-11-21 18:18:37 +00:00
|
|
|
\value NoBreak
|
2015-12-10 05:06:13 +02:00
|
|
|
\value Initial
|
|
|
|
\value Medial
|
2019-11-21 18:18:37 +00:00
|
|
|
\value Final
|
|
|
|
\value Isolated
|
|
|
|
\value Circle
|
2015-12-10 05:06:13 +02:00
|
|
|
\value Super
|
2019-11-21 18:18:37 +00:00
|
|
|
\value Sub
|
2015-12-10 05:06:13 +02:00
|
|
|
\value Vertical
|
|
|
|
\value Wide
|
2019-11-21 18:18:37 +00:00
|
|
|
\value Narrow
|
|
|
|
\value Small
|
|
|
|
\value Square
|
|
|
|
\value Compat
|
|
|
|
\value Fraction
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa decomposition()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::Joining
|
|
|
|
|
|
|
|
This enum type defines the Unicode joining attributes. See the
|
|
|
|
\l{http://www.unicode.org/}{Unicode Standard} for a description
|
|
|
|
of the values.
|
|
|
|
|
|
|
|
\value Dual
|
|
|
|
\value OtherJoining
|
|
|
|
\value Right
|
2019-07-23 20:02:45 +00:00
|
|
|
\value Left
|
|
|
|
\value Causing
|
|
|
|
\value Transparent
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa joining()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QChar::SpecialCharacter
|
|
|
|
|
|
|
|
\value Null A QChar with this value isNull().
|
|
|
|
\value Nbsp Non-breaking space.
|
|
|
|
\value ReplacementCharacter The character shown when a font has no glyph
|
|
|
|
for a certain codepoint. A special question mark character is often
|
|
|
|
used. Codecs use this codepoint when input data cannot be
|
|
|
|
represented in Unicode.
|
|
|
|
\value ObjectReplacementCharacter Used to represent an object such as an
|
|
|
|
image when such objects cannot be presented.
|
|
|
|
\value ByteOrderMark
|
|
|
|
\value ByteOrderSwapped
|
|
|
|
\value ParagraphSeparator
|
|
|
|
\value LineSeparator
|
|
|
|
|
|
|
|
\omitvalue null
|
|
|
|
\omitvalue replacement
|
|
|
|
\omitvalue byteOrderMark
|
|
|
|
\omitvalue byteOrderSwapped
|
|
|
|
\omitvalue nbsp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn void QChar::setCell(const uchar cell)
|
2015-12-10 05:06:13 +02:00
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn void QChar::setRow(const uchar row)
|
2015-12-10 05:06:13 +02:00
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QChar::QChar()
|
|
|
|
|
|
|
|
Constructs a null QChar ('\\0').
|
|
|
|
|
|
|
|
\sa isNull()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const QLatin1Char ch)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const SpecialCharacter ch)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for the predefined character value \a ch.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Constructs a QChar corresponding to ASCII/Latin-1 character \a
|
|
|
|
ch.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
QChar::QChar(const char ch)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
|
|
|
#ifndef QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
if (QTextCodec::codecForCStrings())
|
|
|
|
// #####
|
|
|
|
ucs = QTextCodec::codecForCStrings()->toUnicode(&ch, 1).at(0).unicode();
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ucs = uchar(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
QChar::QChar(const uchar ch)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
|
|
|
#ifndef QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
if (QTextCodec::codecForCStrings()) {
|
|
|
|
// #####
|
2016-10-05 13:23:46 +00:00
|
|
|
const char c = char(ch);
|
2015-12-10 05:06:13 +02:00
|
|
|
ucs = QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
ucs = ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const uchar cell, const uchar row)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for Unicode cell \a cell in row \a row.
|
|
|
|
|
|
|
|
\sa cell(), row()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(uconst short code)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for the character with Unicode code point \a
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const short code)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for the character with Unicode code point \a
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const uint code)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for the character with Unicode code point \a
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2016-10-05 13:23:46 +00:00
|
|
|
\fn QChar::QChar(const int code)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
Constructs a QChar for the character with Unicode code point \a
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::isNull() const
|
|
|
|
|
|
|
|
Returns true if the character is the Unicode character 0x0000
|
|
|
|
('\\0'); otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn uchar QChar::cell() const
|
|
|
|
|
|
|
|
Returns the cell (least significant byte) of the Unicode
|
|
|
|
character.
|
|
|
|
|
|
|
|
\sa row()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn uchar QChar::row() const
|
|
|
|
|
|
|
|
Returns the row (most significant byte) of the Unicode character.
|
|
|
|
|
|
|
|
\sa cell()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a printable character; otherwise
|
|
|
|
returns false. This is any character not of category Cc or Cn.
|
|
|
|
|
|
|
|
Note that this gives no indication of whether the character is
|
|
|
|
available in a particular font.
|
|
|
|
*/
|
|
|
|
bool QChar::isPrint() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isprint(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a separator character
|
|
|
|
(Separator_* categories); otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isSpace() const
|
|
|
|
{
|
2019-07-24 10:53:05 +00:00
|
|
|
if(ucs >= 9 && ucs <= 13)
|
2015-12-10 05:06:13 +02:00
|
|
|
return true;
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isblank(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a mark (Mark_* categories);
|
|
|
|
otherwise returns false.
|
|
|
|
|
|
|
|
See QChar::Category for more information regarding marks.
|
|
|
|
*/
|
|
|
|
bool QChar::isMark() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
const int8_t category = u_charType(ucs);
|
2019-07-23 20:02:45 +00:00
|
|
|
switch (category) {
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_NON_SPACING_MARK:
|
|
|
|
case U_COMBINING_SPACING_MARK:
|
|
|
|
case U_ENCLOSING_MARK:
|
2019-07-23 20:02:45 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a punctuation mark (Punctuation_*
|
|
|
|
categories); otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isPunct() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_ispunct(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a letter (Letter_* categories);
|
|
|
|
otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isLetter() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isalpha(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a number (Number_* categories,
|
|
|
|
not just 0-9); otherwise returns false.
|
|
|
|
|
|
|
|
\sa isDigit()
|
|
|
|
*/
|
|
|
|
bool QChar::isNumber() const
|
|
|
|
{
|
2019-07-23 20:02:45 +00:00
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return is_ascii_number(ucs);
|
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isxdigit(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a letter or number (Letter_* or
|
|
|
|
Number_* categories); otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isLetterOrNumber() const
|
|
|
|
{
|
2019-07-23 20:02:45 +00:00
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return is_ascii_letterornumber(ucs);
|
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isalnum(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a decimal digit
|
|
|
|
(Number_DecimalDigit); otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isDigit() const
|
|
|
|
{
|
2019-07-23 20:02:45 +00:00
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return is_ascii_number(ucs);
|
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isdigit(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a symbol (Symbol_* categories);
|
|
|
|
otherwise returns false.
|
|
|
|
*/
|
|
|
|
bool QChar::isSymbol() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
const int8_t category = u_charType(ucs);
|
2019-07-23 20:02:45 +00:00
|
|
|
switch (category) {
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_MATH_SYMBOL:
|
|
|
|
case U_CURRENCY_SYMBOL:
|
|
|
|
case U_MODIFIER_SYMBOL:
|
|
|
|
case U_OTHER_SYMBOL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::isHighSurrogate() const
|
|
|
|
|
|
|
|
Returns true if the QChar is the high part of a utf16 surrogate
|
|
|
|
(ie. if its code point is between 0xd800 and 0xdbff, inclusive).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::isLowSurrogate() const
|
|
|
|
|
|
|
|
Returns true if the QChar is the low part of a utf16 surrogate
|
|
|
|
(ie. if its code point is between 0xdc00 and 0xdfff, inclusive).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static bool QChar::isHighSurrogate(uint ucs4)
|
|
|
|
\since 4.7
|
|
|
|
|
|
|
|
Returns true if the UCS-4-encoded character specified by \a ucs4
|
|
|
|
is the high part of a utf16 surrogate
|
|
|
|
(ie. if its code point is between 0xd800 and 0xdbff, inclusive).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static bool QChar::isLowSurrogate(uint ucs4)
|
|
|
|
\since 4.7
|
|
|
|
|
|
|
|
Returns true if the UCS-4-encoded character specified by \a ucs4
|
|
|
|
is the low part of a utf16 surrogate
|
|
|
|
(ie. if its code point is between 0xdc00 and 0xdfff, inclusive).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static bool QChar::requiresSurrogates(uint ucs4)
|
|
|
|
\since 4.7
|
|
|
|
|
|
|
|
Returns true if the UCS-4-encoded character specified by \a ucs4
|
|
|
|
can be split into the high and low parts of a utf16 surrogate
|
|
|
|
(ie. if its code point is greater than or equals to 0x10000).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static uint QChar::surrogateToUcs4(ushort high, ushort low)
|
|
|
|
|
|
|
|
Converts a UTF16 surrogate pair with the given \a high and \a low values
|
|
|
|
to its UCS-4 code point.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static uint QChar::surrogateToUcs4(QChar high, QChar low)
|
|
|
|
|
|
|
|
Converts a utf16 surrogate pair (\a high, \a low) to its ucs4 code point.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static ushort QChar::highSurrogate(uint ucs4)
|
|
|
|
|
|
|
|
Returns the high surrogate value of a ucs4 code point.
|
|
|
|
The returned result is undefined if \a ucs4 is smaller than 0x10000.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static ushort QChar::lowSurrogate(uint ucs4)
|
|
|
|
|
|
|
|
Returns the low surrogate value of a ucs4 code point.
|
|
|
|
The returned result is undefined if \a ucs4 is smaller than 0x10000.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the numeric value of the digit, or -1 if the character is
|
|
|
|
not a digit.
|
|
|
|
*/
|
|
|
|
int QChar::digitValue() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::digitValue(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Returns the numeric value of the digit, specified by the UCS-2-encoded
|
|
|
|
character, \a ucs2, or -1 if the character is not a digit.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
int QChar::digitValue(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::digitValue(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Returns the numeric value of the digit specified by the UCS-4-encoded
|
|
|
|
character, \a ucs4, or -1 if the character is not a digit.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
int QChar::digitValue(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_digit(ucs4, 10);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the character's category.
|
|
|
|
*/
|
|
|
|
QChar::Category QChar::category() const
|
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
return QChar::category(uint(ucs));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:44:13 +00:00
|
|
|
|
2015-12-10 05:06:13 +02:00
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-25 09:44:13 +00:00
|
|
|
Returns the category of the UCS-2-encoded character specified by \a ucs2.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-25 09:44:13 +00:00
|
|
|
QChar::Category QChar::category(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
return QChar::category(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-25 09:44:13 +00:00
|
|
|
\since 4.3
|
|
|
|
Returns the category of the UCS-4-encoded character specified by \a ucs4.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-25 09:44:13 +00:00
|
|
|
QChar::Category QChar::category(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
const int8_t category = u_charType(ucs4);
|
|
|
|
switch (category) {
|
|
|
|
case U_GENERAL_OTHER_TYPES:
|
|
|
|
return QChar::Other_NotAssigned;
|
|
|
|
case U_UPPERCASE_LETTER:
|
|
|
|
return QChar::Letter_Uppercase;
|
|
|
|
case U_LOWERCASE_LETTER:
|
|
|
|
return QChar::Letter_Lowercase;
|
|
|
|
case U_TITLECASE_LETTER:
|
|
|
|
return QChar::Letter_Titlecase;
|
|
|
|
case U_MODIFIER_LETTER:
|
|
|
|
return QChar::Letter_Modifier;
|
|
|
|
case U_OTHER_LETTER:
|
|
|
|
return QChar::Letter_Other;
|
|
|
|
case U_NON_SPACING_MARK:
|
|
|
|
return QChar::Mark_NonSpacing;
|
|
|
|
case U_COMBINING_SPACING_MARK:
|
|
|
|
return QChar::Mark_SpacingCombining;
|
|
|
|
case U_ENCLOSING_MARK:
|
|
|
|
return QChar::Mark_Enclosing;
|
|
|
|
case U_DECIMAL_DIGIT_NUMBER:
|
|
|
|
return QChar::Number_DecimalDigit;
|
|
|
|
case U_LETTER_NUMBER:
|
|
|
|
return QChar::Number_Letter;
|
|
|
|
case U_OTHER_NUMBER:
|
|
|
|
return QChar::Number_Other;
|
|
|
|
case U_CONNECTOR_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_Connector;
|
|
|
|
case U_DASH_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_Dash;
|
|
|
|
case U_START_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_Open;
|
|
|
|
case U_END_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_Close;
|
|
|
|
case U_INITIAL_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_InitialQuote;
|
|
|
|
case U_FINAL_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_FinalQuote;
|
|
|
|
case U_OTHER_PUNCTUATION:
|
|
|
|
return QChar::Punctuation_Other;
|
|
|
|
case U_MATH_SYMBOL:
|
|
|
|
return QChar::Symbol_Math;
|
|
|
|
case U_CURRENCY_SYMBOL:
|
|
|
|
return QChar::Symbol_Currency;
|
|
|
|
case U_MODIFIER_SYMBOL:
|
|
|
|
return QChar::Symbol_Modifier;
|
|
|
|
case U_OTHER_SYMBOL:
|
|
|
|
return QChar::Symbol_Other;
|
|
|
|
case U_SPACE_SEPARATOR:
|
|
|
|
return QChar::Separator_Space;
|
|
|
|
case U_LINE_SEPARATOR:
|
|
|
|
return QChar::Separator_Line;
|
|
|
|
case U_PARAGRAPH_SEPARATOR:
|
|
|
|
return QChar::Separator_Paragraph;
|
|
|
|
case U_CONTROL_CHAR:
|
|
|
|
return QChar::Other_Control;
|
|
|
|
case U_FORMAT_CHAR:
|
|
|
|
return QChar::Other_Format;
|
|
|
|
case U_SURROGATE:
|
|
|
|
return QChar::Other_Surrogate;
|
|
|
|
case U_PRIVATE_USE_CHAR:
|
|
|
|
return QChar::Other_PrivateUse;
|
|
|
|
}
|
|
|
|
return QChar::Other_NotAssigned;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the character's direction.
|
|
|
|
*/
|
|
|
|
QChar::Direction QChar::direction() const
|
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
return QChar::direction(uint(ucs));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-25 09:44:13 +00:00
|
|
|
Returns the direction of the UCS-2-encoded character specified by \a ucs2.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-25 09:44:13 +00:00
|
|
|
QChar::Direction QChar::direction(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
return QChar::direction(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-25 09:44:13 +00:00
|
|
|
Returns the direction of the UCS-4-encoded character specified by \a ucs4.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-25 09:44:13 +00:00
|
|
|
QChar::Direction QChar::direction(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-25 09:44:13 +00:00
|
|
|
const UCharDirection direction = u_charDirection(ucs4);
|
|
|
|
switch (direction) {
|
|
|
|
case U_LEFT_TO_RIGHT:
|
|
|
|
return QChar::DirL;
|
|
|
|
case U_LEFT_TO_RIGHT_EMBEDDING:
|
|
|
|
return QChar::DirLRE;
|
|
|
|
case U_LEFT_TO_RIGHT_OVERRIDE:
|
|
|
|
return QChar::DirLRO;
|
|
|
|
case U_RIGHT_TO_LEFT:
|
|
|
|
return QChar::DirR;
|
|
|
|
case U_RIGHT_TO_LEFT_ARABIC:
|
|
|
|
return QChar::DirAL;
|
|
|
|
case U_RIGHT_TO_LEFT_EMBEDDING:
|
|
|
|
return QChar::DirRLE;
|
|
|
|
case U_RIGHT_TO_LEFT_OVERRIDE:
|
|
|
|
return QChar::DirRLO;
|
|
|
|
case U_POP_DIRECTIONAL_FORMAT:
|
|
|
|
return QChar::DirPDF;
|
|
|
|
case U_EUROPEAN_NUMBER:
|
|
|
|
return QChar::DirEN;
|
|
|
|
case U_EUROPEAN_NUMBER_SEPARATOR:
|
|
|
|
return QChar::DirES;
|
|
|
|
case U_EUROPEAN_NUMBER_TERMINATOR:
|
|
|
|
return QChar::DirET;
|
|
|
|
case U_ARABIC_NUMBER:
|
|
|
|
return QChar::DirAN;
|
|
|
|
case U_COMMON_NUMBER_SEPARATOR:
|
|
|
|
return QChar::DirCS;
|
|
|
|
case U_DIR_NON_SPACING_MARK:
|
|
|
|
return QChar::DirNSM;
|
|
|
|
case U_BOUNDARY_NEUTRAL:
|
|
|
|
return QChar::DirBN;
|
|
|
|
case U_BLOCK_SEPARATOR:
|
|
|
|
return QChar::DirB;
|
|
|
|
case U_SEGMENT_SEPARATOR:
|
|
|
|
return QChar::DirS;
|
|
|
|
case U_WHITE_SPACE_NEUTRAL:
|
|
|
|
return QChar::DirWS;
|
|
|
|
case U_OTHER_NEUTRAL:
|
|
|
|
return QChar::DirON;
|
|
|
|
case U_LEFT_TO_RIGHT_ISOLATE:
|
|
|
|
return QChar::DirLRI;
|
|
|
|
case U_RIGHT_TO_LEFT_ISOLATE:
|
|
|
|
return QChar::DirRLI;
|
|
|
|
case U_FIRST_STRONG_ISOLATE:
|
|
|
|
return QChar::DirFSI;
|
|
|
|
case U_POP_DIRECTIONAL_ISOLATE:
|
|
|
|
return QChar::DirPDI;
|
|
|
|
}
|
|
|
|
return QChar::DirL;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns information about the joining properties of the character
|
|
|
|
(needed for certain languages such as Arabic).
|
|
|
|
*/
|
|
|
|
QChar::Joining QChar::joining() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::joining(uint(ucs));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns information about the joining properties of the UCS-2-encoded
|
|
|
|
character specified by \a ucs2 (needed for certain languages such as
|
2015-12-10 05:06:13 +02:00
|
|
|
Arabic).
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
QChar::Joining QChar::joining(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::joining(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns information about the joining properties of the UCS-4-encoded
|
|
|
|
character specified by \a ucs4 (needed for certain languages such as
|
2015-12-10 05:06:13 +02:00
|
|
|
Arabic).
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
QChar::Joining QChar::joining(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
const int32_t property = u_getIntPropertyValue(ucs4, UCHAR_JOINING_TYPE);
|
|
|
|
switch (property) {
|
|
|
|
case U_JT_JOIN_CAUSING:
|
|
|
|
return QChar::Causing;
|
|
|
|
case U_JT_DUAL_JOINING:
|
|
|
|
return QChar::Dual;
|
|
|
|
case U_JT_LEFT_JOINING:
|
|
|
|
return QChar::Left;
|
|
|
|
case U_JT_RIGHT_JOINING:
|
|
|
|
return QChar::Right;
|
|
|
|
case U_JT_TRANSPARENT:
|
|
|
|
return QChar::Transparent;
|
|
|
|
case U_JT_NON_JOINING:
|
|
|
|
// for compatibility
|
|
|
|
return QChar::OtherJoining;
|
|
|
|
}
|
|
|
|
return QChar::OtherJoining;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character should be reversed if the text
|
|
|
|
direction is reversed; otherwise returns false.
|
|
|
|
|
|
|
|
Same as (ch.mirroredChar() != ch).
|
|
|
|
|
|
|
|
\sa mirroredChar()
|
|
|
|
*/
|
|
|
|
bool QChar::hasMirrored() const
|
|
|
|
{
|
2019-07-23 20:02:45 +00:00
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_isMirrored(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if the character is a lowercase letter, i.e.
|
|
|
|
category() is Letter_Lowercase.
|
|
|
|
|
|
|
|
\sa isUpper(), toLower(), toUpper()
|
|
|
|
*/
|
2019-07-23 20:02:45 +00:00
|
|
|
bool QChar::isLower() const
|
|
|
|
{
|
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return is_ascii_lower(ucs);
|
|
|
|
}
|
|
|
|
return category() == Letter_Lowercase;
|
|
|
|
}
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::isUpper() const
|
|
|
|
|
|
|
|
Returns true if the character is an uppercase letter, i.e.
|
|
|
|
category() is Letter_Uppercase.
|
|
|
|
|
|
|
|
\sa isLower(), toUpper(), toLower()
|
|
|
|
*/
|
2019-07-23 20:02:45 +00:00
|
|
|
bool QChar::isUpper() const
|
|
|
|
{
|
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return is_ascii_upper(ucs);
|
|
|
|
}
|
|
|
|
return category() == Letter_Uppercase;
|
|
|
|
}
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::isTitleCase() const
|
|
|
|
\since 4.3
|
|
|
|
|
|
|
|
Returns true if the character is a titlecase letter, i.e.
|
|
|
|
category() is Letter_Titlecase.
|
|
|
|
|
|
|
|
\sa isLower(), toUpper(), toLower(), toTitleCase()
|
|
|
|
*/
|
2019-07-23 20:02:45 +00:00
|
|
|
bool QChar::isTitleCase() const
|
|
|
|
{
|
|
|
|
if (is_ascii_char(ucs)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return category() == Letter_Titlecase;
|
|
|
|
}
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the mirrored character if this character is a mirrored
|
|
|
|
character; otherwise returns the character itself.
|
|
|
|
|
|
|
|
\sa hasMirrored()
|
|
|
|
*/
|
|
|
|
QChar QChar::mirroredChar() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::mirroredChar(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the mirrored character if the UCS-2-encoded character specified
|
|
|
|
by \a ucs2 is a mirrored character; otherwise returns the character itself.
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa hasMirrored()
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
ushort QChar::mirroredChar(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::mirroredChar(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the mirrored character if the UCS-4-encoded character specified
|
|
|
|
by \a ucs4 is a mirrored character; otherwise returns the character itself.
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
\sa hasMirrored()
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
uint QChar::mirroredChar(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_charMirror(ucs4);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Decomposes a character into its parts. Returns an empty string if
|
|
|
|
no decomposition exists.
|
|
|
|
*/
|
|
|
|
QString QChar::decomposition() const
|
|
|
|
{
|
|
|
|
return decomposition(ucs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Decomposes the UCS-4-encoded character specified by \a ucs4 into its
|
|
|
|
constituent parts. Returns an empty string if no decomposition exists.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
QString QChar::decomposition(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
UErrorCode errorcode = U_ZERO_ERROR;
|
|
|
|
const UNormalizer2 *normalizer = unorm2_getNFDInstance(&errorcode);
|
|
|
|
if (Q_UNLIKELY(U_FAILURE(errorcode))) {
|
|
|
|
qWarning("QChar::decomposition: %s", u_errorName(errorcode));
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:51:30 +00:00
|
|
|
errorcode = U_ZERO_ERROR;
|
|
|
|
QString result(4, Qt::Uninitialized);
|
|
|
|
const int decresult = unorm2_getDecomposition(normalizer, ucs4,
|
|
|
|
reinterpret_cast<UChar*>(result.data()), result.size(), &errorcode);
|
2019-07-23 20:02:45 +00:00
|
|
|
if (Q_UNLIKELY(decresult < 1)) {
|
2019-11-21 18:18:37 +00:00
|
|
|
// no decomposition value
|
2019-07-23 20:02:45 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
|
|
|
|
if (Q_UNLIKELY(U_FAILURE(errorcode))) {
|
|
|
|
qWarning("QChar::decomposition: %s", u_errorName(errorcode));
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:51:30 +00:00
|
|
|
result.resize(decresult);
|
|
|
|
return result;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the tag defining the composition of the character. Returns
|
|
|
|
QChar::Single if no decomposition exists.
|
|
|
|
*/
|
|
|
|
QChar::Decomposition QChar::decompositionTag() const
|
|
|
|
{
|
|
|
|
return decompositionTag(ucs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Returns the tag defining the composition of the UCS-4-encoded character
|
|
|
|
specified by \a ucs4. Returns QChar::Single if no decomposition exists.
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
QChar::Decomposition QChar::decompositionTag(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
const int32_t property = u_getIntPropertyValue(ucs4, UCHAR_DECOMPOSITION_TYPE);
|
|
|
|
switch (property) {
|
|
|
|
case U_DT_CANONICAL:
|
|
|
|
return QChar::Canonical;
|
|
|
|
case U_DT_FONT:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Font;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_NOBREAK:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::NoBreak;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_INITIAL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Initial;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_MEDIAL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Medial;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_FINAL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Final;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_ISOLATED:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Isolated;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_CIRCLE:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Circle;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_SUPER:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Super;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_SUB:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Sub;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_VERTICAL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Vertical;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_WIDE:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Wide;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_NARROW:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Narrow;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_SMALL:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Small;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_SQUARE:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Square;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_FRACTION:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Fraction;
|
2019-11-21 18:18:37 +00:00
|
|
|
case U_DT_COMPAT:
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Compat;
|
2019-11-21 18:18:37 +00:00
|
|
|
U_DT_NONE:
|
|
|
|
return QChar::NoDecomposition;
|
2019-07-23 20:02:45 +00:00
|
|
|
}
|
|
|
|
return QChar::NoDecomposition;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the Unicode version that introduced this character.
|
|
|
|
*/
|
|
|
|
QChar::UnicodeVersion QChar::unicodeVersion() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::unicodeVersion(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Returns the Unicode version that introduced the character specified in
|
2019-11-21 18:18:37 +00:00
|
|
|
its UCS-2-encoded form as \a ucs2.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
QChar::UnicodeVersion QChar::unicodeVersion(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::unicodeVersion(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
Returns the Unicode version that introduced the character specified in
|
2019-11-21 18:18:37 +00:00
|
|
|
its UCS-4-encoded form as \a ucs4.
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
QChar::UnicodeVersion QChar::unicodeVersion(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
UVersionInfo info;
|
|
|
|
u_charAge(ucs4, info);
|
|
|
|
QByteArray version(U_MAX_VERSION_STRING_LENGTH, Qt::Uninitialized);
|
|
|
|
u_versionToString(info, version.data());
|
|
|
|
|
|
|
|
if (version == "1.1") {
|
|
|
|
return QChar::Unicode_1_1;
|
|
|
|
} else if (version == "2.0") {
|
|
|
|
return QChar::Unicode_2_0;
|
|
|
|
} else if (version == "2.1") {
|
|
|
|
return QChar::Unicode_2_1;
|
|
|
|
} else if (version == "3.0") {
|
|
|
|
return QChar::Unicode_3_0;
|
|
|
|
} else if (version == "3.1") {
|
|
|
|
return QChar::Unicode_3_1;
|
|
|
|
} else if (version == "3.2") {
|
|
|
|
return QChar::Unicode_3_2;
|
|
|
|
} else if (version == "4.0") {
|
|
|
|
return QChar::Unicode_4_0;
|
|
|
|
} else if (version == "4.1") {
|
|
|
|
return QChar::Unicode_4_1;
|
|
|
|
} else if (version == "5.0") {
|
|
|
|
return QChar::Unicode_5_0;
|
|
|
|
} else if (version == "5.1") {
|
|
|
|
return QChar::Unicode_5_1;
|
|
|
|
} else if (version == "5.2") {
|
|
|
|
return QChar::Unicode_5_2;
|
|
|
|
} else if (version == "6.0") {
|
|
|
|
return QChar::Unicode_6_0;
|
|
|
|
} else if (version == "6.1") {
|
|
|
|
return QChar::Unicode_6_1;
|
|
|
|
} else if (version == "6.2") {
|
|
|
|
return QChar::Unicode_6_2;
|
|
|
|
} else if (version == "6.3") {
|
|
|
|
return QChar::Unicode_6_3;
|
|
|
|
} else if (version == "7.0") {
|
|
|
|
return QChar::Unicode_7_0;
|
|
|
|
} else if (version == "8.0") {
|
|
|
|
return QChar::Unicode_8_0;
|
|
|
|
} else if (version == "9.0") {
|
|
|
|
return QChar::Unicode_9_0;
|
|
|
|
} else if (version == "10.0") {
|
|
|
|
return QChar::Unicode_10_0;
|
|
|
|
} else if (version == "11.0") {
|
|
|
|
return QChar::Unicode_11_0;
|
|
|
|
} else if (version == "12.0") {
|
|
|
|
return QChar::Unicode_12_0;
|
|
|
|
} else if (version == "12.1") {
|
|
|
|
return QChar::Unicode_12_1;
|
|
|
|
}
|
|
|
|
return QChar::Unicode_Unassigned;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\since 4.8
|
|
|
|
|
|
|
|
Returns the most recent supported Unicode version.
|
|
|
|
*/
|
|
|
|
QChar::UnicodeVersion QChar::currentUnicodeVersion()
|
|
|
|
{
|
2019-07-23 20:02:45 +00:00
|
|
|
return QChar::Unicode_Last;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the lowercase equivalent if the character is uppercase or titlecase;
|
|
|
|
otherwise returns the character itself.
|
|
|
|
*/
|
|
|
|
QChar QChar::toLower() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toLower(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the lowercase equivalent of the UCS-2-encoded character specified
|
|
|
|
by \a ucs2 if the character is uppercase or titlecase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
ushort QChar::toLower(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toLower(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the lowercase equivalent of the UCS-4-encoded character specified
|
|
|
|
by \a ucs4 if the character is uppercase or titlecase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
uint QChar::toLower(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
if (is_ascii_char(ucs4)) {
|
|
|
|
return to_ascii_lower(ucs4);
|
2019-07-23 20:02:45 +00:00
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_tolower(ucs4);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the uppercase equivalent if the character is lowercase or titlecase;
|
|
|
|
otherwise returns the character itself.
|
|
|
|
*/
|
|
|
|
QChar QChar::toUpper() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toUpper(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the uppercase equivalent of the UCS-2-encoded character specified
|
|
|
|
by \a ucs2 if the character is lowercase or titlecase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
ushort QChar::toUpper(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toUpper(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the uppercase equivalent of the UCS-4-encoded character specified
|
|
|
|
by \a ucs4 if the character is lowercase or titlecase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
uint QChar::toUpper(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
if (is_ascii_char(ucs4)) {
|
|
|
|
return to_ascii_upper(ucs4);
|
2019-07-23 20:02:45 +00:00
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_toupper(ucs4);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the title case equivalent if the character is lowercase or uppercase;
|
|
|
|
otherwise returns the character itself.
|
|
|
|
*/
|
|
|
|
QChar QChar::toTitleCase() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toTitleCase(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the title case equivalent of the UCS-2-encoded character specified
|
|
|
|
by \a ucs2 if the character is lowercase or uppercase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
ushort QChar::toTitleCase(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toTitleCase(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the title case equivalent of the UCS-4-encoded character specified
|
|
|
|
by \a ucs4 if the character is lowercase or uppercase; otherwise returns
|
2015-12-10 05:06:13 +02:00
|
|
|
the character itself.
|
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
uint QChar::toTitleCase(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
if (is_ascii_char(ucs4)) {
|
|
|
|
return to_ascii_upper(ucs4);
|
2019-07-23 20:02:45 +00:00
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_totitle(ucs4);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the case folded equivalent of the character. For most Unicode characters this
|
|
|
|
is the same as toLowerCase().
|
|
|
|
*/
|
|
|
|
QChar QChar::toCaseFolded() const
|
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toCaseFolded(ucs);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the case folded equivalent of the UCS-2-encoded character specified
|
|
|
|
by \a ucs2. For most Unicode characters this is the same as toLowerCase().
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
ushort QChar::toCaseFolded(const ushort ucs2)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
return QChar::toCaseFolded(uint(ucs2));
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
2019-11-21 18:18:37 +00:00
|
|
|
Returns the case folded equivalent of the UCS-4-encoded character specified
|
|
|
|
by \a ucs4. For most Unicode characters this is the same as toLowerCase().
|
2015-12-10 05:06:13 +02:00
|
|
|
*/
|
2019-11-21 18:18:37 +00:00
|
|
|
uint QChar::toCaseFolded(const uint ucs4)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
2019-11-21 18:18:37 +00:00
|
|
|
if (is_ascii_char(ucs4)) {
|
|
|
|
return to_ascii_lower(ucs4);
|
2019-07-23 20:02:45 +00:00
|
|
|
}
|
2019-11-21 18:18:37 +00:00
|
|
|
return u_foldCase(ucs4, U_FOLD_CASE_DEFAULT);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn char QChar::latin1() const
|
|
|
|
|
|
|
|
Use toLatin1() instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn char QChar::ascii() const
|
|
|
|
|
|
|
|
Use toAscii() instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn char QChar::toLatin1() const
|
|
|
|
|
|
|
|
Returns the Latin-1 character equivalent to the QChar, or 0. This
|
|
|
|
is mainly useful for non-internationalized software.
|
|
|
|
|
|
|
|
\sa toAscii(), unicode(), QTextCodec::codecForCStrings()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn char QChar::toAscii() const
|
|
|
|
Returns the character value of the QChar obtained using the current
|
|
|
|
codec used to read C strings, or 0 if the character is not representable
|
|
|
|
using this codec. The default codec handles Latin-1 encoded text,
|
|
|
|
but this can be changed to assist developers writing source code using
|
|
|
|
other encodings.
|
|
|
|
|
|
|
|
The main purpose of this function is to preserve ASCII characters used
|
|
|
|
in C strings. This is mainly useful for developers of non-internationalized
|
|
|
|
software.
|
|
|
|
|
|
|
|
\sa toLatin1(), unicode(), QTextCodec::codecForCStrings()
|
|
|
|
*/
|
|
|
|
char QChar::toAscii() const
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
if (QTextCodec::codecForCStrings())
|
|
|
|
// #####
|
|
|
|
return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0);
|
|
|
|
#endif
|
|
|
|
return ucs > 0xff ? 0 : char(ucs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QChar QChar::fromLatin1(char c)
|
|
|
|
|
|
|
|
Converts the Latin-1 character \a c to its equivalent QChar. This
|
|
|
|
is mainly useful for non-internationalized software.
|
|
|
|
|
|
|
|
\sa fromAscii(), unicode(), QTextCodec::codecForCStrings()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Converts the ASCII character \a c to its equivalent QChar. This
|
|
|
|
is mainly useful for non-internationalized software.
|
|
|
|
|
|
|
|
An alternative is to use QLatin1Char.
|
|
|
|
|
|
|
|
\sa fromLatin1(), unicode(), QTextCodec::codecForCStrings()
|
|
|
|
*/
|
2016-10-05 13:23:46 +00:00
|
|
|
QChar QChar::fromAscii(const char c)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
|
|
|
#ifndef QT_NO_CODEC_FOR_C_STRINGS
|
|
|
|
if (QTextCodec::codecForCStrings())
|
|
|
|
// #####
|
|
|
|
return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
|
|
|
|
#endif
|
|
|
|
return QChar(ushort((uchar)c));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_DATASTREAM
|
|
|
|
/*!
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Writes the char \a chr to the stream \a out.
|
|
|
|
|
|
|
|
\sa {Serializing Qt Data Types}
|
|
|
|
*/
|
|
|
|
QDataStream &operator<<(QDataStream &out, const QChar &chr)
|
|
|
|
{
|
|
|
|
out << quint16(chr.unicode());
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Reads a char from the stream \a in into char \a chr.
|
|
|
|
|
|
|
|
\sa {Serializing Qt Data Types}
|
|
|
|
*/
|
|
|
|
QDataStream &operator>>(QDataStream &in, QChar &chr)
|
|
|
|
{
|
|
|
|
quint16 u;
|
|
|
|
in >> u;
|
|
|
|
chr.unicode() = ushort(u);
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
#endif // QT_NO_DATASTREAM
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn ushort & QChar::unicode()
|
|
|
|
|
|
|
|
Returns a reference to the numeric Unicode value of the QChar.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn ushort QChar::unicode() const
|
|
|
|
|
|
|
|
\overload
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Documentation of QChar related functions
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool operator==(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if \a c1 and \a c2 are the same Unicode character;
|
|
|
|
otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int operator!=(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if \a c1 and \a c2 are not the same Unicode
|
|
|
|
character; otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int operator<=(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if the numeric Unicode value of \a c1 is less than
|
|
|
|
or equal to that of \a c2; otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int operator>=(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if the numeric Unicode value of \a c1 is greater than
|
|
|
|
or equal to that of \a c2; otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int operator<(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if the numeric Unicode value of \a c1 is less than
|
|
|
|
that of \a c2; otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int operator>(QChar c1, QChar c2)
|
|
|
|
|
|
|
|
\relates QChar
|
|
|
|
|
|
|
|
Returns true if the numeric Unicode value of \a c1 is greater than
|
|
|
|
that of \a c2; otherwise returns false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::mirrored() const
|
|
|
|
|
|
|
|
Use hasMirrored() instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QChar QChar::lower() const
|
|
|
|
|
|
|
|
Use toLower() instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QChar QChar::upper() const
|
|
|
|
|
|
|
|
Use toUpper() instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool QChar::networkOrdered()
|
|
|
|
|
|
|
|
See if QSysInfo::ByteOrder == QSysInfo::BigEndian instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|