Char Class Reference

#include <Pt/String.h>

Unicode character type. More...

Public Member Functions

 Char ()
 Default Constructor.
 Char (char ch)
 Construct from char.
 Char (int val)
 Construct from int.
 Char (uint32_t val)
 Construct from unsigned 32-bit integer.
char narrow (char def= '?') const
 Narrows the character to 8-bit. More...
 operator uint32_t () const
 Returns the unicode value.
Charoperator= (const Char &ch)
 Assignment operator.
uint32_t value () const
 Returns the unicode value.

Related Functions

int isalnum (const Char &ch)
 Checks whether ch is a alphanumeric character.
int isalpha (const Char &ch)
 Checks whether ch is a alphabetic character.
int iscntrl (const Char &ch)
 Checks whether ch is a control character.
int isdigit (const Pt::Char &ch)
 Checks whether ch is a decimal digit.
int isgraph (const Char &ch)
 Checks whether ch is a graphical character.
int islower (const Pt::Char &ch)
 Checks whether ch is lower case.
int isprint (const Char &ch)
 Checks whether ch is a printable character.
int ispunct (const Char &ch)
 Checks whether ch is a punctuation character.
int isspace (const Char &ch)
 Checks whether ch is a whitespace character.
int isupper (const Char &ch)
 Checks whether ch is upper case.
int isxdigit (const Char &ch)
 Checks whether ch is a hexadecimal digit.
Pt::Char tolower (const Pt::Char &ch)
 Convert a character to lower case.
Pt::Char toupper (const Pt::Char &ch)
 Convert a character to upper case.

Detailed Description

The unicode character type Pt::Char can directly represent a unicode code point. It is used as the character type for Pt::String or Pt::StringStream. Characters can be classified or transformed using a set of functions similar to what can be found in the cctype header of the standard library:

Pt::Char ch = 'a';
// check character category
assert( isalpha(ch) );
assert( islower(ch) );
// convert to upper case
Pt::Char ch2 = toupper(ch);
assert( isupper(ch) );

Member Function Documentation

char narrow ( char  def = '?') const

The default character def is returned if the unicode value is too large to be narrowed to char i.e. greater than 255.