Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQChar Class Reference

The TQChar class provides a lightweight Unicode character. More...

Almost all the functions in this class are reentrant when TQt is built with thread support. The exception is decomposition().

#include <qstring.h>

List of all member functions.

Public Members

Static Public Members

Related Functions


Detailed Description

The TQChar class provides a lightweight Unicode character.

Unicode characters are (so far) 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 "short int". (In a few years it may be necessary to make TQChar 32-bit when more than 65536 Unicode code points have been defined and come into use.)

TQChar 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 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 U+0000), 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), isLetterOrNumber(), and isDigit() (decimal digits). All of these are wrappers around category() which return the Unicode-defined category of each character.

TQChar further 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 mirrored(), which indicates whether the 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") 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. TQt 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. (See TQString::localeAwareCompare() though.)

The conversion functions include unicode() (to a scalar), latin1() (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.

More information can be found in the document About Unicode.

See also TQString, TQCharRef, and Text Related Classes.


Member Type Documentation

TQChar::Category

This enum maps the Unicode character categories.

The following characters are normative in Unicode:

The following categories are informative in Unicode:

There are two categories that are specific to TQt:

TQChar::CombiningClass

This enum type defines names for some of the Unicode combining classes. See the Unicode Standard for a description of the values.

TQChar::Decomposition

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

TQChar::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.

TQChar::Joining

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


Member Function Documentation

TQChar::TQChar ()

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

TQChar::TQChar ( char c )

Constructs a TQChar corresponding to ASCII/Latin-1 character c.

TQChar::TQChar ( uchar c )

Constructs a TQChar corresponding to ASCII/Latin-1 character c.

TQChar::TQChar ( uchar c, uchar r )

Constructs a TQChar for Unicode cell c in row r.

TQChar::TQChar ( const TQChar & c )

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

TQChar::TQChar ( ushort rc )

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

TQChar::TQChar ( short rc )

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

TQChar::TQChar ( uint rc )

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

TQChar::TQChar ( int rc )

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

Category TQChar::category () const

Returns the character category.

See also Category.

uchar TQChar::cell () const

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

unsigned char TQChar::combiningClass () const

Returns the combining class for the character as defined in the Unicode standard. This is mainly useful as a positioning hint for marks attached to a base character.

The TQt text rendering engine uses this information to correctly position non spacing marks around a base character.

const TQString & TQChar::decomposition () const

Warning: This function is not reentrant.

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

Decomposition TQChar::decompositionTag () const

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

int TQChar::digitValue () const

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

Direction TQChar::direction () const

Returns the character's direction.

See also Direction.

bool TQChar::isDigit () const

Returns TRUE if the character is a decimal digit (Number_DecimalDigit); otherwise returns FALSE.

bool TQChar::isLetter () const

Returns TRUE if the character is a letter (Letter_* categories); otherwise returns FALSE.

bool TQChar::isLetterOrNumber () const

Returns TRUE if the character is a letter or number (Letter_* or Number_* categories); otherwise returns FALSE.

bool TQChar::isMark () const

Returns TRUE if the character is a mark (Mark_* categories); otherwise returns FALSE.

bool TQChar::isNull () const

Returns TRUE if the character is the Unicode character 0x0000 (ASCII NUL); otherwise returns FALSE.

bool TQChar::isNumber () const

Returns TRUE if the character is a number (of any sort - Number_* categories); otherwise returns FALSE.

See also isDigit().

bool TQChar::isPrint () const

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 TQChar::isPunct () const

Returns TRUE if the character is a punctuation mark (Punctuation_* categories); otherwise returns FALSE.

bool TQChar::isSpace () const

Returns TRUE if the character is a separator character (Separator_* categories); otherwise returns FALSE.

bool TQChar::isSymbol () const

Returns TRUE if the character is a symbol (Symbol_* categories); otherwise returns FALSE.

Joining TQChar::joining () const

Warning: This function is not supported (it may change to use Unicode character classes).

Returns information about the joining properties of the character (needed for example, for Arabic).

char TQChar::latin1 () const

Returns the Latin-1 value of this character, or 0 if it cannot be represented in Latin-1.

TQChar TQChar::lower () const

Returns the lowercase equivalent if the character is uppercase; otherwise returns the character itself.

bool TQChar::mirrored () const

Returns TRUE if the character is a mirrored character (one that should be reversed if the text direction is reversed); otherwise returns FALSE.

TQChar TQChar::mirroredChar () const

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

bool TQChar::networkOrdered () [static]

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Returns TRUE if this character is in network byte order (MSB first); otherwise returns FALSE. This is platform dependent.

TQChar::operator char () const

Returns the Latin-1 character equivalent to the TQChar, or 0. This is mainly useful for non-internationalized software.

See also unicode().

uchar TQChar::row () const

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

ushort TQChar::unicode () const

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

ushort & TQChar::unicode ()

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns a reference to the numeric Unicode value equal to the TQChar.

TQChar TQChar::upper () const

Returns the uppercase equivalent if the character is lowercase; otherwise returns the character itself.

Related Functions

int operator!= ( TQChar c1, TQChar c2 )

Returns TRUE if c1 and c2 are not the same Unicode character; otherwise returns FALSE.

int operator!= ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if c is not the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator!= ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if c is not the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator< ( TQChar c1, TQChar c2 )

Returns TRUE if the numeric Unicode value of c1 is less than that of c2; otherwise returns FALSE.

int operator< ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of c is less than that of the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator< ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 character ch is less than that of c; otherwise returns FALSE.

int operator<= ( TQChar c1, TQChar c2 )

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

int operator<= ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of c is less than or equal to that of the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator<= ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 character ch is less than or equal to that of c; otherwise returns FALSE.

bool operator== ( TQChar c1, TQChar c2 )

Returns TRUE if c1 and c2 are the same Unicode character; otherwise returns FALSE.

bool operator== ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if c is the ASCII/Latin-1 character ch; otherwise returns FALSE.

bool operator== ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if c is the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator> ( TQChar c1, TQChar c2 )

Returns TRUE if the numeric Unicode value of c1 is greater than that of c2; otherwise returns FALSE.

int operator> ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of c is greater than that of the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator> ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 character ch is greater than that of c; otherwise returns FALSE.

int operator>= ( TQChar c1, TQChar c2 )

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

int operator>= ( TQChar c, char ch )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of c is greater than or equal to that of the ASCII/Latin-1 character ch; otherwise returns FALSE.

int operator>= ( char ch, TQChar c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 character ch is greater than or equal to that of c; otherwise returns FALSE.


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8