Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QChar Class Reference

List of all members.

Detailed Description

The QChar class provides a 16-bit Unicode character.

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

QChar provides constructors and cast operators that make it easy to convert to and from traditional 8-bit {char}s. If you defined QT_NO_CAST_FROM_ASCII and 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 char, and you will need to call toAscii() or toLatin1() to get the 8-bit value back.

See also:
QString, Unicode, QLatin1Char

Definition at line 67 of file qchar.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_Dash, Punctuation_Open, Punctuation_Close,
  Punctuation_InitialQuote, Punctuation_FinalQuote, Punctuation_Other, Symbol_Math,
  Symbol_Currency, Symbol_Modifier, Symbol_Other, Punctuation_Dask = Punctuation_Dash
enum  CombiningClass {
  Combining_BelowLeftAttached = 200, Combining_BelowAttached = 202, Combining_BelowRightAttached = 204, Combining_LeftAttached = 208,
  Combining_RightAttached = 210, Combining_AboveLeftAttached = 212, Combining_AboveAttached = 214, Combining_AboveRightAttached = 216,
  Combining_BelowLeft = 218, Combining_Below = 220, Combining_BelowRight = 222, Combining_Left = 224,
  Combining_Right = 226, Combining_AboveLeft = 228, Combining_Above = 230, Combining_AboveRight = 232,
  Combining_DoubleBelow = 233, Combining_DoubleAbove = 234, Combining_IotaSubscript = 240
enum  Decomposition {
  NoDecomposition, Canonical, Font, NoBreak,
  Initial, Medial, Final, Isolated,
  Circle, Super, Sub, Vertical,
  Wide, Narrow, Small, Square,
  Compat, Fraction
enum  Direction {
  DirL, DirR, DirEN, DirES,
  DirET, DirAN, DirCS, DirB,
  DirS, DirWS, DirON, DirLRE,
  DirLRO, DirAL, DirRLE, DirRLO,
  DirPDF, DirNSM, DirBN
enum  Joining { OtherJoining, Dual, Right, Center }
enum  SpecialCharacter {
  Null = 0x0000, Nbsp = 0x00a0, ReplacementCharacter = 0xfffd, ObjectReplacementCharacter = 0xfffc,
  ByteOrderMark = 0xfeff, ByteOrderSwapped = 0xfffe, ParagraphSeparator = 0x2029, LineSeparator = 0x2028
enum  UnicodeVersion {
  Unicode_Unassigned, Unicode_1_1, Unicode_2_0, Unicode_2_1_2,
  Unicode_3_0, Unicode_3_1, Unicode_3_2, Unicode_4_0,
  Unicode_4_1, Unicode_5_0

Public Member Functions

Category category () const
uchar cell () const
unsigned char combiningClass () const
QString decomposition () const
Decomposition decompositionTag () const
int digitValue () const
Direction direction () const
bool hasMirrored () const
bool isDigit () const
bool isHighSurrogate () const
bool isLetter () const
bool isLetterOrNumber () const
bool isLower () const
bool isLowSurrogate () const
bool isMark () const
bool isNull () const
bool isNumber () const
bool isPrint () const
bool isPunct () const
bool isSpace () const
bool isSymbol () const
bool isTitleCase () const
bool isUpper () const
Joining joining () const
QChar mirroredChar () const
 QChar (SpecialCharacter sc)
 QChar (int rc)
 QChar (uint rc)
 QChar (short rc)
 QChar (ushort rc)
 QChar (uchar c, uchar r)
 QChar (QLatin1Char ch)
 QChar ()
uchar row () const
void setCell (uchar cell)
void setRow (uchar row)
const char toAscii () const
QChar toCaseFolded () const
const char toLatin1 () const
QChar toLower () const
QChar toTitleCase () const
QChar toUpper () const
ushort & unicode ()
const ushort unicode () const
UnicodeVersion unicodeVersion () const

Static Public Member Functions

static Category QT_FASTCALL category (ushort ucs2)
static Category QT_FASTCALL category (uint ucs4)
static unsigned char QT_FASTCALL combiningClass (ushort ucs2)
static unsigned char QT_FASTCALL combiningClass (uint ucs4)
static QString QT_FASTCALL decomposition (uint ucs4)
static Decomposition QT_FASTCALL decompositionTag (uint ucs4)
static int QT_FASTCALL digitValue (ushort ucs2)
static int QT_FASTCALL digitValue (uint ucs4)
static Direction QT_FASTCALL direction (ushort ucs2)
static Direction QT_FASTCALL direction (uint ucs4)
static QChar fromAscii (char c)
static QChar fromLatin1 (char c)
static ushort highSurrogate (uint ucs4)
static Joining QT_FASTCALL joining (ushort ucs2)
static Joining QT_FASTCALL joining (uint ucs4)
static ushort lowSurrogate (uint ucs4)
static ushort QT_FASTCALL mirroredChar (ushort ucs2)
static uint QT_FASTCALL mirroredChar (uint ucs4)
static uint surrogateToUcs4 (QChar high, QChar low)
static uint surrogateToUcs4 (ushort high, ushort low)
static ushort QT_FASTCALL toCaseFolded (ushort ucs2)
static uint QT_FASTCALL toCaseFolded (uint ucs4)
static ushort QT_FASTCALL toLower (ushort ucs2)
static uint QT_FASTCALL toLower (uint ucs4)
static ushort QT_FASTCALL toTitleCase (ushort ucs2)
static uint QT_FASTCALL toTitleCase (uint ucs4)
static ushort QT_FASTCALL toUpper (ushort ucs2)
static uint QT_FASTCALL toUpper (uint ucs4)
static UnicodeVersion QT_FASTCALL unicodeVersion (ushort ucs2)
static UnicodeVersion QT_FASTCALL unicodeVersion (uint ucs4)

Private Attributes

ushort ucs

Related Functions

(Note that these are not member functions.)

int operator!= (QChar c1, QChar c2)
int operator< (QChar c1, QChar c2)
QDataStreamoperator<< (QDataStream &out, const QChar &chr)
int operator<= (QChar c1, QChar c2)
bool operator== (QChar c1, QChar c2)
int operator> (QChar c1, QChar c2)
int operator>= (QChar c1, QChar c2)
QDataStreamoperator>> (QDataStream &in, QChar &chr)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index