The QChar class provides a light-weight Unicode character. More...
#include <qstring.h>
Public Types | |
enum | Category { NoCategory, Mark_NonSpacing, Mark_SpacingCombining, Mark_Enclosing, Number_DecimalDigit, Number_Letter, Number_Other, Separator_Space, Separator_Line, Separator_Paragraph, Other_Control, Other_Format, Other_Surrogate, Other_PrivateUse, Other_NotAssigned, Letter_Uppercase, Letter_Lowercase, Letter_Titlecase, Letter_Modifier, Letter_Other, Punctuation_Connector, Punctuation_Dask, Punctuation_Open, Punctuation_Close, Punctuation_InitialQuote, Punctuation_FinalQuote, Punctuation_Other, Symbol_Math, Symbol_Currency, Symbol_Modifier, Symbol_Other } |
enum | Direction { DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON, DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN } |
enum | Decomposition { Single, Canonical, Font, NoBreak, Initial, Medial, Final, Isolated, Circle, Super, Sub, Vertical, Wide, Narrow, Small, Square, Compat, Fraction } |
enum | Joining { OtherJoining, Dual, Right, Center } |
Public Member Functions | |
QChar () | |
QChar (char c) | |
QChar (uchar c) | |
QChar (uchar c, uchar r) | |
QChar (const QChar &c) | |
QChar (ushort rc) | |
QChar (short rc) | |
QChar (uint rc) | |
QChar (int rc) | |
int | digitValue () const |
QChar | lower () const |
QChar | upper () const |
Category | category () const |
Direction | direction () const |
Joining | joining () const |
bool | mirrored () const |
QChar | mirroredChar () const |
QString | decomposition () const |
Decomposition | decompositionTag () const |
char | latin1 () const |
ushort | unicode () const |
operator char () const | |
bool | isNull () const |
bool | isPrint () const |
bool | isPunct () const |
bool | isSpace () const |
bool | isMark () const |
bool | isLetter () const |
bool | isNumber () const |
bool | isLetterOrNumber () const |
bool | isDigit () const |
uchar & | cell () |
uchar & | row () |
uchar | cell () const |
uchar | row () const |
Static Public Member Functions | |
static bool | networkOrdered () |
Public Attributes | |
QT_STATIC_CONST QChar | null |
QT_STATIC_CONST QChar | replacement |
QT_STATIC_CONST QChar | byteOrderMark |
QT_STATIC_CONST QChar | byteOrderSwapped |
QT_STATIC_CONST QChar | nbsp |
Private Types | |
enum | { net_ordered = 1 } |
Private Attributes | |
uchar | rw |
uchar | cl |
Friends | |
int | operator== (char ch, QChar c) |
int | operator== (QChar c, char ch) |
int | operator== (QChar c1, QChar c2) |
int | operator!= (QChar c1, QChar c2) |
int | operator!= (char ch, QChar c) |
int | operator!= (QChar c, char ch) |
int | operator<= (QChar c, char ch) |
int | operator<= (char ch, QChar c) |
int | operator<= (QChar c1, QChar c2) |
Related Functions | |
(Note that these are not member functions.) | |
int | operator>= (QChar c1, QChar c2) |
int | operator>= (QChar c, char ch) |
int | operator>= (char ch, QChar c) |
int | operator< (QChar c1, QChar c2) |
int | operator< (QChar c, char ch) |
int | operator< (char ch, QChar c) |
int | operator> (QChar c1, QChar c2) |
int | operator> (QChar c, char ch) |
int | operator> (char ch, QChar c) |
The QChar class provides a light-weight Unicode character.
Unicode characters are (so far) 16-bit entities without any markup or structure. This class represents such an entity. It is rather light-weight, so it can be used everywhere. Most compilers treat it approximately like "short int". (In a few years, it may be necessary to make QChar 32-bit, once more than 65536 Unicode code points have been defined and come into use.)
QChar provides a full complement of testing/classification functions, conversion to and from other formats, from composed to decomposed unicode, and will try to compare and case-convert if you ask it to.
The classification functions include functions like those in ctype.h, but operating on the full range of unicode characters. They all return TRUE if the character is a certain type of character, and FALSE otherwise.
These functions are: isNull() (returns TRUE if the character is U+0000), isPrint() (TRUE if the character is any sort of printable character, including whitespace), isPunct() (any sort of punctation), isMark() (Unicode Marks), isLetter (letters), isNumber() (any sort of numeric characters), isLetterOrNumber(), and isDigit() (decimal digits). All of these are wrappers around category(), which returns the unicode-defined category of each character.
QChar further provides direction(), which indicates the "natural" writing direction of this character, joining(), which indicates how this character joins with its neighbors (needed mostly for Arabic) and finally mirrored(), which indicates whether this character needs to be mirrored when it is printed in its unnatural writing direction.
Composed Unicode characters (like å) can be converted to decomposed Unicode ("a" followed by "ring above") using decomposition().
In Unicode, comparison is not necessarily possible, and case conversion is at best very hard. Unicode, covering the "entire" globe, also includes a globe-sized collection of case and sorting problems. Qt tries, but not very hard: operator== and friends will do comparison based purely on the numeric Unicode value (code point) of the characters, and upper() and lower() will do case changes when the character has a well-defined upper/lower-case equivalent. There is no provision for locale-dependent case folding rules or comparison: These functions are meant to be fast, so they can be used unambiguously in data structures.
The conversion functions include unicode() (to a scalar), latin1() (to scalar, but converts all non-Latin1 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.
|
private |
enum QChar::Category |
This enum maps the Unicode character categories. The currently known categories are:
NoCategory
- used when Qt is dazed and confused and cannot make sense of anything.
Mark_NonSpacing
- (Mn) -
Mark_SpacingCombining
- (Mc) -
Mark_Enclosing
- (Me) -
Number_DecimalDigit
- (Nd) -
Number_Letter
- (Nl) -
Number_Other
- (No) -
Separator_Space
- (Zs) -
Separator_Line
- (Zl) -
Separator_Paragraph
- (Zp) -
Other_Control
- (Cc) -
Other_Format
- (Cf) -
Other_Surrogate
- (Cs) -
Other_PrivateUse
- (Co) -
Other_NotAssigned
- (Cn) -
Letter_Uppercase
- (Lu) -
Letter_Lowercase
- (Ll) -
Letter_Titlecase
- (Lt) -
Letter_Modifier
- (Lm) -
Letter_Other
- (Lo) -
Punctuation_Connector
- (Pc) -
Punctuation_Dask
- (Pd) -
Punctuation_Open
- (Ps) -
Punctuation_Close
- (Pe) -
Punctuation_InitialQuote
- (Pi) -
Punctuation_FinalQuote
- (Pf) -
Punctuation_Other
- (Po) -
Symbol_Math
- (Sm) -
Symbol_Currency
- (Sc) -
Symbol_Modifier
- (Sk) -
Symbol_Other
- (So) -
Definition at line 76 of file qstring.h.
enum QChar::Decomposition |
This enum type defines the Unicode decomposition attributes. See the Unicode Standard for a description of the values.
Enumerator | |
---|---|
Single | |
Canonical | |
Font | |
NoBreak | |
Initial | |
Medial | |
Final | |
Isolated | |
Circle | |
Super | |
Sub | |
Vertical | |
Wide | |
Narrow | |
Small | |
Square | |
Compat | |
Fraction |
Definition at line 124 of file qstring.h.
enum QChar::Direction |
This enum type defines the Unicode direction attributes. See the 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.
Enumerator | |
---|---|
DirL | |
DirR | |
DirEN | |
DirES | |
DirET | |
DirAN | |
DirCS | |
DirB | |
DirS | |
DirWS | |
DirON | |
DirLRE | |
DirLRO | |
DirAL | |
DirRLE | |
DirRLO | |
DirPDF | |
DirNSM | |
DirBN |
Definition at line 118 of file qstring.h.
enum QChar::Joining |
This enum type defines the Unicode decomposition attributes. See the Unicode Standard for a description of the values.
Enumerator | |
---|---|
OtherJoining | |
Dual | |
Right | |
Center |
Definition at line 131 of file qstring.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
QChar::Category QChar::category | ( | ) | const |
Returns the character category.
Definition at line 11096 of file qstring.cpp.
|
inline |
|
inline |
QString QChar::decomposition | ( | ) | const |
Decomposes a character into its parts. Returns QString::null if no decomposition exists.
Definition at line 11186 of file qstring.cpp.
QChar::Decomposition QChar::decompositionTag | ( | ) | const |
Returns the tag defining the composition of the character. Returns QChar::Single if no decomposition exists.
Definition at line 11210 of file qstring.cpp.
int QChar::digitValue | ( | ) | const |
Returns the numeric value of the digit, or -1 if the character is not a digit.
Definition at line 11075 of file qstring.cpp.
QChar::Direction QChar::direction | ( | ) | const |
Returns the characters directionality.
Definition at line 11114 of file qstring.cpp.
bool QChar::isDigit | ( | ) | const |
Returns whether the character is a decimal digit (Number_DecimalDigit).
Definition at line 11066 of file qstring.cpp.
bool QChar::isLetter | ( | ) | const |
Returns whether the character is a letter (Letter_* categories).
Definition at line 11035 of file qstring.cpp.
bool QChar::isLetterOrNumber | ( | ) | const |
Returns whether the character is a letter or number (Letter_* or Number_* categories).
Definition at line 11055 of file qstring.cpp.
bool QChar::isMark | ( | ) | const |
Returns whether the character is a mark (Mark_* categories).
Definition at line 11017 of file qstring.cpp.
|
inline |
bool QChar::isNumber | ( | ) | const |
Returns whether the character is a number (of any sort - Number_* categories).
Definition at line 11046 of file qstring.cpp.
bool QChar::isPrint | ( | ) | const |
Returns whether the character is a printable character. This is any character not of category Cc or Cn. Note that this gives no indication of whether the character is available in some font.
Definition at line 10996 of file qstring.cpp.
bool QChar::isPunct | ( | ) | const |
Returns whether the character is punctuation (Punctuation_* categories).
Definition at line 11026 of file qstring.cpp.
bool QChar::isSpace | ( | ) | const |
Returns whether the character is a separator character (Separator_* categories).
Definition at line 11006 of file qstring.cpp.
QChar::Joining QChar::joining | ( | ) | const |
This function is not supported (it may change to use Unicode character classes).
Returns information about the joining properties of the character (needed for arabic).
Definition at line 11132 of file qstring.cpp.
|
inline |
QChar QChar::lower | ( | ) | const |
Returns the lowercase equivalent if the character is uppercase, or the character itself otherwise.
Definition at line 11229 of file qstring.cpp.
bool QChar::mirrored | ( | ) | const |
Returns whether the character is a mirrored character (one that should be reversed if the text direction is reversed).
Definition at line 11149 of file qstring.cpp.
QChar QChar::mirroredChar | ( | ) | const |
Returns the mirrored char if this character is a mirrored char, the char itself otherwise
Definition at line 11165 of file qstring.cpp.
|
inlinestatic |
Returns TRUE if this character is in network byte order (MSB first), and FALSE if it is not. This is a platform-dependent property, so we strongly advise against using this function in portable code.
Definition at line 172 of file qstring.h.
|
inline |
|
inline |
|
inline |
|
inline |
QChar QChar::upper | ( | ) | const |
Returns the uppercase equivalent if the character is lowercase, or the character itself otherwise.
Definition at line 11248 of file qstring.cpp.
|
friend |
|
friend |
|
related |
|
related |
|
friend |
|
friend |
|
friend |
|
friend |
|
related |
|
related |
|
related |
|
related |
QT_STATIC_CONST_IMPL QChar QChar::byteOrderMark |
QT_STATIC_CONST_IMPL QChar QChar::byteOrderSwapped |
QT_STATIC_CONST_IMPL QChar QChar::nbsp |
QT_STATIC_CONST_IMPL QChar QChar::null |
QT_STATIC_CONST_IMPL QChar QChar::replacement |