HomeHome

ClassesAnnotated - TreeFunctionsHomeStructure

QChar Class Reference


The QChar class provides a light-weight Unicode character. More...

#include <qstring.h>

List of all member functions.

Public Members

Static Public Members

Related Functions

(Note that these are not member functions.)

Detailed Description

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.

See also QString, QCharRef and About Unicode


Member Type Documentation

QChar::Category

This enum maps the Unicode character categories. The currently known categories are:

QChar::Decomposition

This enum type defines the Unicode decomposition attributes. See the Unicode Standard for a description of the values.

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.

QChar::Joining

This enum type defines the Unicode decomposition attributes. See the Unicode Standard for a description of the values.

Member Function Documentation

QChar::QChar ()

Constructs a null QChar (one that isNull()).

QChar::QChar ( char c )

Constructs a QChar corresponding to ASCII/Latin1 character c.

QChar::QChar ( const QChar & c )

Constructs a copy of c. This is a deep copy, if such a light-weight object can be said to have deep copies.

QChar::QChar ( int rc )

Constructs a QChar for the character with Unicode code point rc.

QChar::QChar ( short rc )

Constructs a QChar for the character with Unicode code point rc.

QChar::QChar ( uchar c )

Constructs a QChar corresponding to ASCII/Latin1 character c.

QChar::QChar ( uchar c, uchar r )

Constructs a QChar for Unicode cell c in row r.

QChar::QChar ( uint rc )

Constructs a QChar for the character with Unicode code point rc.

QChar::QChar ( ushort rc )

Constructs a QChar for the character with Unicode code point rc.

QChar::operator char () const

Returns the Latin1 character equivalent to the QChar, or 0. This is mainly useful for non-internationalized software.

See also unicode().

QChar::Category QChar::category() const

Returns the character category.

See also Category.

uchar QChar::cell () const

Returns the cell (least significant byte) of the Unicode character.

uchar& QChar::cell ()

Returns a reference to the cell (least significant byte) of the Unicode character.

QString QChar::decomposition () const

Decomposes a character into its parts. Returns QString::null if no decomposition exists.

QChar::Decomposition QChar::decompositionTag() const

Returns the tag defining the composition of the character. Returns QChar::Single if no decomposition exists.

int QChar::digitValue () const

Returns the numeric value of the digit, or -1 if the character is not a digit.

QChar::Direction QChar::direction() const

Returns the characters directionality.

See also Direction.

bool QChar::isDigit () const

Returns whether the character is a decimal digit (Number_DecimalDigit).

bool QChar::isLetter () const

Returns whether the character is a letter (Letter_* categories).

bool QChar::isLetterOrNumber () const

Returns whether the character is a letter or number (Letter_* or Number_* categories).

bool QChar::isMark () const

Returns whether the character is a mark (Mark_* categories).

bool QChar::isNull () const

Returns TRUE if the characters is the unicode character 0x0000, ie. ASCII NUL.

bool QChar::isNumber () const

Returns whether the character is a number (of any sort - Number_* categories).

See also isDigit().

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.

bool QChar::isPunct () const

Returns whether the character is punctuation (Punctuation_* categories).

bool QChar::isSpace () const

Returns whether the character is a separator character (Separator_* categories).

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).

char QChar::latin1 () const

Returns a latin-1 copy of this character, if this character is in the latin-1 character set. If not, this function returns 0.

QChar QChar::lower () const

Returns the lowercase equivalent if the character is uppercase, or the character itself otherwise.

bool QChar::mirrored () const

Returns whether the character is a mirrored character (one that should be reversed if the text direction is reversed).

QChar QChar::mirroredChar () const

Returns the mirrored char if this character is a mirrored char, the char itself otherwise.

bool QChar::networkOrdered () [static]

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.

uchar QChar::row () const

Returns the row (most significant byte) of the Unicode character.

uchar& QChar::row ()

Returns a reference to the row (most significant byte) of the Unicode character.

ushort QChar::unicode () const

Returns the numeric Unicode value equal to the QChar. Normally, you should use QChar objects as they are equivalent, but for some low-level tasks (eg. indexing into an array of Unicode information), this function is useful.

QChar QChar::upper () const

Returns the uppercase equivalent if the character is lowercase, or the character itself otherwise.


Related Functions

int operator<= (QChar c, char ch)

Returns TRUE if the numeric Unicode value of c is less than or equal to that of the ASCII/Latin1 character ch.

int operator>= (QChar c1, QChar c2)

Returns TRUE if the numeric Unicode value of c1 is greater than that of c2, or they are the same Unicode character.

int operator>= (char ch, QChar c)

Returns TRUE if the numeric Unicode value of the ASCII/Latin1 character ch is greater than or equal to that of c.

int operator!= (QChar c, char ch)

Returns TRUE if c is not the ASCII/Latin1 character ch.

int operator>= (QChar c, char ch)

Returns TRUE if the numeric Unicode value of c is greater than or equal to that of the ASCII/Latin1 character ch.

int operator!= (QChar c1, QChar c2)

Returns TRUE if c1 and c2 are not the same Unicode character.

int operator!= (char ch, QChar c)

Returns TRUE if c is not the ASCII/Latin1 character ch.

int operator<= (QChar c1, QChar c2)

Returns TRUE if the numeric Unicode value of c1 is less than that of c2, or they are the same Unicode character.

int operator> (char ch, QChar c)

Returns TRUE if the numeric Unicode value of the ASCII/Latin1 character ch is greater than that of c.

int operator< (QChar c1, QChar c2)

Returns TRUE if the numeric Unicode value of c1 is less than that of c2.

int operator== (QChar c1, QChar c2)

Returns TRUE if c1 and c2 are the same Unicode character.

int operator<= (char ch, QChar c)

Returns TRUE if the numeric Unicode value of the ASCII/Latin1 character ch is less than or equal to that of c.

int operator> (QChar c1, QChar c2)

Returns TRUE if the numeric Unicode value of c1 is greater than that of c2.

int operator< (char ch, QChar c)

Returns TRUE if the numeric Unicode value of the ASCII/Latin1 character ch is less than that of c.

int operator> (QChar c, char ch)

Returns TRUE if the numeric Unicode value of c is greater than that of the ASCII/Latin1 character ch.

int operator< (QChar c, char ch)

Returns TRUE if the numeric Unicode value of c is less than that of the ASCII/Latin1 character ch.

int operator== (char ch, QChar c)

Returns TRUE if c is the ASCII/Latin1 character ch.

int operator== (QChar c, char ch)

Returns TRUE if c is the ASCII/Latin1 character ch.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.


Copyright © 2000 TrolltechTrademarks
Qt version 2.2.1