Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Attributes | Friends | Related Functions | List of all members
QChar Class Reference

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
 
ucharcell ()
 
ucharrow ()
 
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)
 

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 About Unicode

Definition at line 56 of file qstring.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
net_ordered 

Definition at line 193 of file qstring.h.

193 { net_ordered = 1 };

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

Enumerator
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 

Definition at line 76 of file qstring.h.

77  {
78  NoCategory,
79 
80  Mark_NonSpacing, // Mn
82  Mark_Enclosing, // Me
83 
84  Number_DecimalDigit, // Nd
85  Number_Letter, // Nl
86  Number_Other, // No
87 
88  Separator_Space, // Zs
89  Separator_Line, // Zl
90  Separator_Paragraph, // Zp
91 
92  Other_Control, // Cc
93  Other_Format, // Cf
94  Other_Surrogate, // Cs
95  Other_PrivateUse, // Co
96  Other_NotAssigned, // Cn
97 
98  Letter_Uppercase, // Lu
99  Letter_Lowercase, // Ll
100  Letter_Titlecase, // Lt
101  Letter_Modifier, // Lm
102  Letter_Other, // Lo
103 
104  Punctuation_Connector, // Pc
105  Punctuation_Dask, // Pd
106  Punctuation_Open, // Ps
107  Punctuation_Close, // Pe
110  Punctuation_Other, // Po
111 
112  Symbol_Math, // Sm
113  Symbol_Currency, // Sc
114  Symbol_Modifier, // Sk
115  Symbol_Other // So
116  };

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.

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.

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.

Constructor & Destructor Documentation

QChar::QChar ( )
inline

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

Definition at line 205 of file qstring.h.

206 {
207  rw = 0; cl = 0;
208 #ifdef QT_QSTRING_UCS_4
209  grp = 0;
210 #endif
211 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
QChar::QChar ( char  c)
inline

Constructs a QChar corresponding to ASCII/Latin1 character c.

Definition at line 212 of file qstring.h.

213 {
214  rw = 0; cl = (uchar)c;
215 #ifdef QT_QSTRING_UCS_4
216  grp = 0;
217 #endif
218 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
unsigned char uchar
Definition: nybbler.cc:11
QChar::QChar ( uchar  c)
inline

Constructs a QChar corresponding to ASCII/Latin1 character c.

Definition at line 219 of file qstring.h.

220 {
221  rw = 0; cl = c;
222 #ifdef QT_QSTRING_UCS_4
223  grp = 0;
224 #endif
225 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
QChar::QChar ( uchar  c,
uchar  r 
)
inline

Constructs a QChar for Unicode cell c in row r.

Definition at line 226 of file qstring.h.

227 {
228  rw = r; cl = c;
229 #ifdef QT_QSTRING_UCS_4
230  grp = 0;
231 #endif
232 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
QChar::QChar ( const QChar c)
inline

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

Definition at line 233 of file qstring.h.

234 {
235  rw = c.rw; cl = c.cl;
236 #ifdef QT_QSTRING_UCS_4
237  grp = 0;
238 #endif
239 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
QChar::QChar ( ushort  rc)
inline

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

Definition at line 240 of file qstring.h.

241 {
242  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
243 #ifdef QT_QSTRING_UCS_4
244  grp = 0;
245 #endif
246 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
unsigned char uchar
Definition: nybbler.cc:11
QChar::QChar ( short  rc)
inline

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

Definition at line 247 of file qstring.h.

248 {
249  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
250 #ifdef QT_QSTRING_UCS_4
251  grp = 0;
252 #endif
253 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
unsigned char uchar
Definition: nybbler.cc:11
QChar::QChar ( uint  rc)
inline

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

Definition at line 254 of file qstring.h.

255 {
256  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
257 #ifdef QT_QSTRING_UCS_4
258  grp = 0;
259 #endif
260 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
unsigned char uchar
Definition: nybbler.cc:11
QChar::QChar ( int  rc)
inline

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

Definition at line 261 of file qstring.h.

262 {
263  rw = (uchar)((rc>>8)&0xff); cl = (uchar)(rc&0xff);
264 #ifdef QT_QSTRING_UCS_4
265  grp = 0;
266 #endif
267 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
unsigned char uchar
Definition: nybbler.cc:11

Member Function Documentation

QChar::Category QChar::category ( ) const

Returns the character category.

See also
Category

Definition at line 11096 of file qstring.cpp.

11097 {
11098 #ifndef QT_NO_UNICODETABLES
11099  return (Category)(unicode_info[row()][cell()]);
11100 #else
11101 // ### just ASCII
11102  if ( rw == 0 ) {
11103  return (Category)(ui_00[cell()]);
11104  }
11105  return Letter_Uppercase; //#######
11106 #endif
11107 }
Category
Definition: qstring.h:76
uchar rw
Definition: qstring.h:188
uchar & cell()
Definition: qstring.h:167
static const Q_UINT8 ui_00[]
Definition: qstring.cpp:370
static const Q_UINT8 *const unicode_info[256]
Definition: qstring.cpp:2367
uchar & row()
Definition: qstring.h:168
uchar & QChar::cell ( )
inline

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

Definition at line 167 of file qstring.h.

167 { return cl; }
uchar cl
Definition: qstring.h:189
uchar QChar::cell ( ) const
inline

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

Definition at line 169 of file qstring.h.

169 { return cl; }
uchar cl
Definition: qstring.h:189
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.

11187 {
11188 #ifndef QT_NO_UNICODETABLES
11189  const Q_UINT16 *r = decomposition_info[row()];
11190  if(!r) return QString::null;
11191 
11192  Q_UINT16 pos = r[cell()];
11193  if(!pos) return QString::null;
11194  pos+=2;
11195 
11196  QString s;
11197  Q_UINT16 c;
11198  while((c = decomposition_map[pos++]) != 0) s += QChar(c);
11199 
11200  return s;
11201 #else
11202  return null;
11203 #endif
11204 }
QChar()
Definition: qstring.h:205
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
uchar & cell()
Definition: qstring.h:167
unsigned short Q_UINT16
Definition: qglobal.h:418
QT_STATIC_CONST QChar null
Definition: qstring.h:68
uchar & row()
Definition: qstring.h:168
static const Q_UINT16 decomposition_map[]
Definition: qstring.cpp:2403
static const Null null
Definition: qstring.h:376
static const Q_UINT16 *const decomposition_info[256]
Definition: qstring.cpp:7151
static QCString * s
Definition: config.cpp:1042
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.

11211 {
11212 #ifndef QT_NO_UNICODETABLES
11213  const Q_UINT16 *r = decomposition_info[row()];
11214  if(!r) return QChar::Single;
11215 
11216  Q_UINT16 pos = r[cell()];
11217  if(!pos) return QChar::Single;
11218 
11220 #else
11221  return Single; // ########### FIX eg. just latin1
11222 #endif
11223 }
uchar & cell()
Definition: qstring.h:167
unsigned short Q_UINT16
Definition: qglobal.h:418
uchar & row()
Definition: qstring.h:168
static const Q_UINT16 decomposition_map[]
Definition: qstring.cpp:2403
static const Q_UINT16 *const decomposition_info[256]
Definition: qstring.cpp:7151
Decomposition
Definition: qstring.h:124
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.

11076 {
11077 #ifndef QT_NO_UNICODETABLES
11078  const Q_INT8 *dec_row = decimal_info[row()];
11079  if( !dec_row )
11080  return -1;
11081  return decimal_info[row()][cell()];
11082 #else
11083  // ##### just latin1
11084  if ( rw != 0 || cl < '0' || cl > '9' )
11085  return -1;
11086  else
11087  return cl - '0';
11088 #endif
11089 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
uchar & cell()
Definition: qstring.h:167
signed char Q_INT8
Definition: qglobal.h:415
static const Q_INT8 *const decimal_info[256]
Definition: qstring.cpp:10631
uchar & row()
Definition: qstring.h:168
QChar::Direction QChar::direction ( ) const

Returns the characters directionality.

See also
Direction

Definition at line 11114 of file qstring.cpp.

11115 {
11116 #ifndef QT_NO_UNICODETABLES
11117  const Q_UINT8 *rowp = direction_info[row()];
11118  if(!rowp) return QChar::DirL;
11119  return (Direction) ( *(rowp+cell()) &0x1f );
11120 #else
11121  return DirL;
11122 #endif
11123 }
unsigned char Q_UINT8
Definition: qglobal.h:416
uchar & cell()
Definition: qstring.h:167
Direction
Definition: qstring.h:118
static const Q_UINT8 *const direction_info[256]
Definition: qstring.cpp:9781
uchar & row()
Definition: qstring.h:168
bool QChar::isDigit ( ) const

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

Definition at line 11066 of file qstring.cpp.

11067 {
11068  return (category() == Number_DecimalDigit);
11069 }
Category category() const
Definition: qstring.cpp:11096
bool QChar::isLetter ( ) const

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

Definition at line 11035 of file qstring.cpp.

11036 {
11037  Category c = category();
11038  return (c >= Letter_Uppercase && c <= Letter_Other);
11039 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
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.

11056 {
11057  Category c = category();
11058  return (c >= Letter_Uppercase && c <= Letter_Other)
11059  || (c >= Number_DecimalDigit && c <= Number_Other);
11060 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
bool QChar::isMark ( ) const

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

Definition at line 11017 of file qstring.cpp.

11018 {
11019  Category c = category();
11020  return c >= Mark_NonSpacing && c <= Mark_Enclosing;
11021 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
bool QChar::isNull ( ) const
inline

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

Definition at line 157 of file qstring.h.

157 { return unicode()==0; }
ushort unicode() const
Definition: qstring.h:151
bool QChar::isNumber ( ) const

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

See also
isDigit()

Definition at line 11046 of file qstring.cpp.

11047 {
11048  Category c = category();
11049  return c >= Number_DecimalDigit && c <= Number_Other;
11050 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
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.

10997 {
10998  Category c = category();
10999  return !(c == Other_Control || c == Other_NotAssigned);
11000 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
bool QChar::isPunct ( ) const

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

Definition at line 11026 of file qstring.cpp.

11027 {
11028  Category c = category();
11029  return (c >= Punctuation_Connector && c <= Punctuation_Other);
11030 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
bool QChar::isSpace ( ) const

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

Definition at line 11006 of file qstring.cpp.

11007 {
11008  if( !row() )
11009  if( cell() >= 9 && cell() <=13 ) return TRUE;
11010  Category c = category();
11011  return c >= Separator_Space && c <= Separator_Paragraph;
11012 }
Category
Definition: qstring.h:76
Category category() const
Definition: qstring.cpp:11096
uchar & cell()
Definition: qstring.h:167
uchar & row()
Definition: qstring.h:168
const bool TRUE
Definition: qglobal.h:371
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.

11133 {
11134 #ifndef QT_NO_UNICODETABLES
11135  const Q_UINT8 *rowp = direction_info[row()];
11136  if ( !rowp )
11137  return QChar::OtherJoining;
11138  return (Joining) ((*(rowp+cell()) >> 5) &0x3);
11139 #else
11140  return OtherJoining;
11141 #endif
11142 }
Joining
Definition: qstring.h:131
unsigned char Q_UINT8
Definition: qglobal.h:416
uchar & cell()
Definition: qstring.h:167
static const Q_UINT8 *const direction_info[256]
Definition: qstring.cpp:9781
uchar & row()
Definition: qstring.h:168
char QChar::latin1 ( ) const
inline

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

Definition at line 150 of file qstring.h.

150 { return rw ? 0 : cl; }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
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.

11230 {
11231 #ifndef QT_NO_UNICODETABLES
11232  if(category() != Letter_Uppercase) return *this;
11233  Q_UINT16 lower = *(case_info[row()]+cell());
11234  if(lower == 0) return *this;
11235  return lower;
11236 #else
11237  if (row())
11238  return *this;
11239  else
11240  return QChar(tolower(latin1()));
11241 #endif
11242 }
QChar()
Definition: qstring.h:205
Category category() const
Definition: qstring.cpp:11096
uchar & cell()
Definition: qstring.h:167
QChar lower() const
Definition: qstring.cpp:11229
unsigned short Q_UINT16
Definition: qglobal.h:418
char latin1() const
Definition: qstring.h:150
uchar & row()
Definition: qstring.h:168
static const Q_UINT16 *const case_info[256]
Definition: qstring.cpp:10280
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.

11150 {
11151 #ifndef QT_NO_UNICODETABLES
11152  const Q_UINT8 *rowp = direction_info[row()];
11153  if ( !rowp )
11154  return FALSE;
11155  return *(rowp+cell())>128;
11156 #else
11157  return FALSE;
11158 #endif
11159 }
const bool FALSE
Definition: qglobal.h:370
unsigned char Q_UINT8
Definition: qglobal.h:416
uchar & cell()
Definition: qstring.h:167
static const Q_UINT8 *const direction_info[256]
Definition: qstring.cpp:9781
uchar & row()
Definition: qstring.h:168
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.

11166 {
11167 #ifndef QT_NO_UNICODETABLES
11168  if(!mirrored()) return *this;
11169 
11170  int i;
11171  int c = unicode();
11172  for (i = 0; i < symmetricPairsSize; i += 2) {
11173  if (symmetricPairs[i] == c)
11174  return symmetricPairs[i+1];
11175  }
11176  return 0;
11177 #else
11178  return *this;
11179 #endif
11180 }
ushort unicode() const
Definition: qstring.h:151
static int symmetricPairsSize
Definition: qstring.cpp:10681
static const Q_UINT16 symmetricPairs[]
Definition: qstring.cpp:10666
bool mirrored() const
Definition: qstring.cpp:11149
bool QChar::networkOrdered ( )
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.

172 { return (int)net_ordered == 1; }
QChar::operator char ( ) const
inline

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

See also
unicode()

Definition at line 154 of file qstring.h.

154 { return latin1(); }
char latin1() const
Definition: qstring.h:150
uchar & QChar::row ( )
inline

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

Definition at line 168 of file qstring.h.

168 { return rw; }
uchar rw
Definition: qstring.h:188
uchar QChar::row ( ) const
inline

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

Definition at line 170 of file qstring.h.

170 { return rw; }
uchar rw
Definition: qstring.h:188
ushort QChar::unicode ( ) const
inline

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.

Definition at line 151 of file qstring.h.

151 { return (rw << 8) | cl; }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
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.

11249 {
11250 #ifndef QT_NO_UNICODETABLES
11251  if(category() != Letter_Lowercase) return *this;
11252  Q_UINT16 upper = *(case_info[row()]+cell());
11253  if(upper == 0) return *this;
11254  return upper;
11255 #else
11256  if (row())
11257  return *this;
11258  else
11259  return QChar(toupper(latin1()));
11260 #endif
11261 }
QChar()
Definition: qstring.h:205
Category category() const
Definition: qstring.cpp:11096
uchar & cell()
Definition: qstring.h:167
unsigned short Q_UINT16
Definition: qglobal.h:418
char latin1() const
Definition: qstring.h:150
uchar & row()
Definition: qstring.h:168
static const Q_UINT16 *const case_info[256]
Definition: qstring.cpp:10280
QChar upper() const
Definition: qstring.cpp:11248

Friends And Related Function Documentation

int operator!= ( QChar  c1,
QChar  c2 
)
friend

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

Definition at line 286 of file qstring.h.

287 {
288  return c1.cl != c2.cl
289  || c1.rw != c2.rw;
290 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator!= ( char  ch,
QChar  c 
)
friend

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

Definition at line 292 of file qstring.h.

293 {
294  return ch != c.cl || c.rw;
295 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator!= ( QChar  c,
char  ch 
)
friend

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

Definition at line 297 of file qstring.h.

298 {
299  return ch != c.cl || c.rw;
300 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator< ( QChar  c1,
QChar  c2 
)
related

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

Definition at line 326 of file qstring.h.

326 { return !(c2<=c1); }
int operator< ( QChar  c,
char  ch 
)
related

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

Definition at line 324 of file qstring.h.

324 { return !(ch<=c); }
int operator< ( char  ch,
QChar  c 
)
related

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

Definition at line 325 of file qstring.h.

325 { return !(c<=ch); }
int operator<= ( QChar  c,
char  ch 
)
friend

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

Definition at line 302 of file qstring.h.

303 {
304  return !(ch < c.cl || c.rw);
305 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator<= ( char  ch,
QChar  c 
)
friend

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

Definition at line 307 of file qstring.h.

308 {
309  return ch <= c.cl || c.rw;
310 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator<= ( QChar  c1,
QChar  c2 
)
friend

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

Definition at line 312 of file qstring.h.

313 {
314  return c1.rw > c2.rw
315  ? FALSE
316  : c1.rw < c2.rw
317  ? TRUE
318  : c1.cl <= c2.cl;
319 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
const bool FALSE
Definition: qglobal.h:370
const bool TRUE
Definition: qglobal.h:371
int operator== ( char  ch,
QChar  c 
)
friend

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

Definition at line 270 of file qstring.h.

271 {
272  return ch == c.cl && !c.rw;
273 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator== ( QChar  c,
char  ch 
)
friend

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

Definition at line 275 of file qstring.h.

276 {
277  return ch == c.cl && !c.rw;
278 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator== ( QChar  c1,
QChar  c2 
)
friend

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

Definition at line 280 of file qstring.h.

281 {
282  return c1.cl == c2.cl
283  && c1.rw == c2.rw;
284 }
uchar cl
Definition: qstring.h:189
uchar rw
Definition: qstring.h:188
int operator> ( QChar  c1,
QChar  c2 
)
related

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

Definition at line 329 of file qstring.h.

329 { return !(c2>=c1); }
int operator> ( QChar  c,
char  ch 
)
related

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

Definition at line 327 of file qstring.h.

327 { return !(ch>=c); }
int operator> ( char  ch,
QChar  c 
)
related

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

Definition at line 328 of file qstring.h.

328 { return !(c>=ch); }
int operator>= ( QChar  c1,
QChar  c2 
)
related

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

Definition at line 323 of file qstring.h.

323 { return c2 <= c1; }
int operator>= ( QChar  c,
char  ch 
)
related

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

Definition at line 321 of file qstring.h.

321 { return ch <= c; }
int operator>= ( char  ch,
QChar  c 
)
related

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

Definition at line 322 of file qstring.h.

322 { return c <= ch; }

Member Data Documentation

QT_STATIC_CONST_IMPL QChar QChar::byteOrderMark

Definition at line 70 of file qstring.h.

QT_STATIC_CONST_IMPL QChar QChar::byteOrderSwapped

Definition at line 71 of file qstring.h.

uchar QChar::cl
private

Definition at line 189 of file qstring.h.

Definition at line 72 of file qstring.h.

Definition at line 68 of file qstring.h.

QT_STATIC_CONST_IMPL QChar QChar::replacement

Definition at line 69 of file qstring.h.

uchar QChar::rw
private

Definition at line 188 of file qstring.h.


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