QChar(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QChar πŸ’– β€” the <rainbow>lightweight Unicode character</rainbow> situation, from the QChar(3qt) manual

Bestie. Sit down. We're doing Unicode today and honestly? It's giving main character energy. πŸ¦‹


🌸 NAME 🌸

QChar β€” a lightweight Unicode character. That's the whole rΓ©sumΓ©. Iconic, minimal, slays. πŸ’…


✨ SYNOPSIS ✨

Okay so first thing, and this one is important so I'm putting it up top: almost all the functions in this class are reentrant when Qt is built with thread support. The one exception is decomposition(). Not her. She's not reentrant, she said so herself.

Also there's a stray </p> floating at the end of that sentence in the original manual. We don't ask questions. We respect the chaos. πŸ’€
#include <qstring.h>

πŸŽ€ Public Members πŸŽ€

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 )
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_Dask = Punctuation_Dash,
    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 }
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 }
int digitValue () const
QChar lower () const
QChar upper () const
Category category () const
Direction direction () const
Joining joining () const
bool mirrored () const
QChar mirroredChar () const
const QString & decomposition () const
Decomposition decompositionTag () const
unsigned char combiningClass () const
char latin1 () const
ushort unicode () const
ushort & unicode ()
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
bool isSymbol () const
uchar cell () const
uchar row () const

πŸ‘‘ Static Public Members πŸ‘‘

bool networkOrdered ()  (obsolete)

Yes, networkOrdered() is obsolete. It's still here. It's a legacy queen. Leave her be. πŸ™ˆ


These are the operators that hang out outside the class but are absolutely part of the friend group:

bool operator== ( QChar c1, QChar c2 )
bool operator== ( char ch, QChar c )
bool operator== ( QChar c, char ch )
int operator!= ( QChar c1, QChar c2 )
int operator!= ( char ch, QChar c )
int operator!= ( QChar c, char ch )
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 )
int operator> ( QChar c1, QChar c2 )
int operator> ( QChar c, char ch )
int operator> ( char ch, QChar c )

πŸ’œ DESCRIPTION πŸ’œ

The QChar 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". (And heads up: in a few years it may be necessary to make QChar 32-bit when more than 65536 Unicode code points have been defined and come into use. Growth era fr fr. 🌱)

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

QChar 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 &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. 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. (See QString::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 QString, QCharRef, and Text Related Classes.


🌈 Member Type Documentation 🌈

QChar::Category

This enum maps the Unicode character categories.

The following characters are normative in Unicode:

  • QChar::Mark_NonSpacing β€” Unicode class name Mn
  • QChar::Mark_SpacingCombining β€” Unicode class name Mc
  • QChar::Mark_Enclosing β€” Unicode class name Me
  • QChar::Number_DecimalDigit β€” Unicode class name Nd
  • QChar::Number_Letter β€” Unicode class name Nl
  • QChar::Number_Other β€” Unicode class name No
  • QChar::Separator_Space β€” Unicode class name Zs
  • QChar::Separator_Line β€” Unicode class name Zl
  • QChar::Separator_Paragraph β€” Unicode class name Zp
  • QChar::Other_Control β€” Unicode class name Cc
  • QChar::Other_Format β€” Unicode class name Cf
  • QChar::Other_Surrogate β€” Unicode class name Cs
  • QChar::Other_PrivateUse β€” Unicode class name Co
  • QChar::Other_NotAssigned β€” Unicode class name Cn

The following categories are informative in Unicode:

  • QChar::Letter_Uppercase β€” Unicode class name Lu
  • QChar::Letter_Lowercase β€” Unicode class name Ll
  • QChar::Letter_Titlecase β€” Unicode class name Lt
  • QChar::Letter_Modifier β€” Unicode class name Lm
  • QChar::Letter_Other β€” Unicode class name Lo
  • QChar::Punctuation_Connector β€” Unicode class name Pc
  • QChar::Punctuation_Dash β€” Unicode class name Pd
  • QChar::Punctuation_Open β€” Unicode class name Ps
  • QChar::Punctuation_Close β€” Unicode class name Pe
  • QChar::Punctuation_InitialQuote β€” Unicode class name Pi
  • QChar::Punctuation_FinalQuote β€” Unicode class name Pf
  • QChar::Punctuation_Other β€” Unicode class name Po
  • QChar::Symbol_Math β€” Unicode class name Sm
  • QChar::Symbol_Currency β€” Unicode class name Sc
  • QChar::Symbol_Modifier β€” Unicode class name Sk
  • QChar::Symbol_Other β€” Unicode class name So

There are two categories that are specific to Qt:

  • QChar::NoCategory β€” used when Qt is dazed and confused and cannot make sense of anything. (Same, honestly. 😭)
  • QChar::Punctuation_Dask β€” old typo alias for Punctuation_Dash. It's a typo. It's canon. We keep it. 🫢

QChar::CombiningClass

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

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 joining attributes. See the Unicode Standard for a description of the values.


πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–

QChar::QChar ()

Constructs a null QChar β€” one that isNull(). Blank canvas. Empty page. Fresh start. πŸŽ€

QChar::QChar ( char c )

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

QChar::QChar ( uchar c )

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

QChar::QChar ( uchar c, uchar r )

Constructs a QChar for Unicode cell c in row r. Cell-and-row girlies, this one's for you.

QChar::QChar ( const QChar & c )

Constructs a copy of c. This is a deep copy, if such a lightweight object can be said to have deep copies. (She's small but she contains multitudes, okay? ✨)

QChar::QChar ( ushort 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 ( uint rc )

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

QChar::QChar ( int rc )

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

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.

unsigned char QChar::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 Qt text rendering engine uses this information to correctly position non spacing marks around a base character.

const QString & QChar::decomposition () const

Warning: This function is not reentrant. Also yes, there's another stray </p> at the end of that warning in the original. We keep it. It's part of the lore now. πŸ’€

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

Decomposition QChar::decompositionTag () const

okay so this one hands you the tag that defines the composition of the character. if there's no decomposition, it just says QChar::Single. simple as that, bestie ✨


int QChar::digitValue () const

gives you the numeric value of the digit, or -1 if the character is not a digit. no cap πŸ’…


Direction QChar::direction () const

returns the character's direction. peep Direction for more deets. 🧭


bool QChar::isDigit () const

returns TRUE if the character is a decimal digit (Number_DecimalDigit); otherwise returns FALSE. slay πŸ”’


bool QChar::isLetter () const

returns TRUE if the character is a letter (Letter_* categories); otherwise returns FALSE. letters are iconic πŸ”€


bool QChar::isLetterOrNumber () const

returns TRUE if the character is a letter or number (Letter_* or Number_* categories); otherwise returns FALSE. both? we love versatility ✨


bool QChar::isMark () const

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


bool QChar::isNull () const

returns TRUE if the character is the Unicode character 0x0000 (ASCII NUL); otherwise returns FALSE. null vibes πŸ’€


bool QChar::isNumber () const

returns TRUE if the character is a number (of any sort - Number_* categories); otherwise returns FALSE. see also isDigit(). πŸ”’


bool QChar::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. so don't @ me if your font doesn't have it πŸ™ˆ

bool QChar::isPunct () const

returns TRUE if the character is a punctuation mark (Punctuation_* categories); otherwise returns FALSE. punctuation is the seasoning of text πŸŽ€


bool QChar::isSpace () const

returns TRUE if the character is a separator character (Separator_* categories); otherwise returns FALSE. space, the final frontier 🌌


bool QChar::isSymbol () const

returns TRUE if the character is a symbol (Symbol_* categories); otherwise returns FALSE. symbols are the main character energy πŸ’–


Joining QChar::joining () const

warning: this function is not supported (it may change to use Unicode character classes). so don't get too attached πŸ’”

returns information about the joining properties of the character (needed for example, for Arabic). iykyk 🌍


char QChar::latin1 () const

returns the Latin-1 value of this character, or 0 if it cannot be represented in Latin-1. if it's not latin-1, you get a big fat zero 0️⃣


QChar QChar::lower () const

returns the lowercase equivalent if the character is uppercase; otherwise returns the character itself. lowercase and unbothered πŸ’…


bool QChar::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. mirror mirror on the wall πŸͺž


QChar QChar::mirroredChar () const

returns the mirrored character if this character is a mirrored character, otherwise returns the character itself. no mirror? it's giving original ✨


bool QChar::networkOrdered () [static]

this function is obsolete. it is provided to keep old source working. we strongly advise against using it in new code. literally do not use this in new code, bestie 🚫

returns TRUE if this character is in network byte order (MSB first); otherwise returns FALSE. this is platform dependent. platform dependent? messy πŸ’€


QChar::operator char () const

returns the Latin-1 character equivalent to the QChar, or 0. this is mainly useful for non-internationalized software. see also unicode(). 🌐


uchar QChar::row () const

returns the row (most significant byte) of the Unicode character. row row row your byte 🚣


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 (e.g. indexing into an array of Unicode information), this function is useful. low-level? we love a niche use case πŸ”


ushort & QChar::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 QChar. reference? we stan 🫢


QChar QChar::upper () const

returns the uppercase equivalent if the character is lowercase; otherwise returns the character itself. uppercase and thriving πŸ‘‘


int operator!= ( QChar c1, QChar c2 )

returns TRUE if c1 and c2 are not the same Unicode character; otherwise returns FALSE. not equal? we love a distinction πŸ’…


int operator!= ( char ch, QChar 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. char vs QChar, the showdown βš”οΈ


int operator!= ( QChar 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. same energy, different order πŸ”„


int operator< ( QChar c1, QChar c2 )

returns TRUE if the numeric Unicode value of c1 is less than that of c2; otherwise returns FALSE. less than? we love a comparison πŸ“‰


int operator< ( QChar 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. comparing apples and oranges? kinda 🍎🍊


int operator< ( char ch, QChar 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. flip the script πŸ”„


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; otherwise returns FALSE. less than or equal? inclusive queen πŸ‘‘


int operator<= ( QChar 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. inclusive vibes ✨


int operator<= ( char ch, QChar 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. still inclusive πŸ’…


bool operator== ( QChar c1, QChar c2 )

returns TRUE if c1 and c2 are the same Unicode character; otherwise returns FALSE. twinning πŸ‘―


bool operator== ( char ch, QChar 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. match made in heaven πŸ’–


bool operator== ( QChar 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. same same but different order πŸ”„


int operator> ( QChar c1, QChar c2 )

returns TRUE if the numeric Unicode value of c1 is greater than that of c2; otherwise returns FALSE. greater than? we love an overachiever πŸ“ˆ


int operator> ( QChar 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. beating the competition πŸ†


int operator> ( char ch, QChar 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. flip it and reverse it πŸ”„


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; otherwise returns FALSE. greater than or equal? inclusive AND overachieving πŸ‘‘


int operator>= ( QChar 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. inclusive and thriving ✨


int operator>= ( char ch, QChar 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. last but not least πŸ’…


🌈 SEE ALSO 🌈


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


πŸŽ€ AUTHOR πŸŽ€

Generated automatically from the source code.


πŸ¦‹ BUGS πŸ¦‹

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qchar.3qt) and the Qt version (3.3.8).


and that's a wrap, bestie! this page was brought to you by Trolltech AS, dated 2 February 2007, and it's the QChar(3qt) man page. stay iconic, stay Unicode. πŸ’…βœ¨

πŸ“¦ where this page comes from