This example application demonstrates how to use TChar
, TCharF
, TCharLC
and TCharUC
classes.
TChar
represents a single character. It stores
the character's value as a 32-bit unsigned integer and it provides
various functions to manipulate the character and retrieve its properties.
TChar and its derived classes can be used to represent Unicode
values outside plane 0 (that is, Unicode values within the
extended Unicode range from 0x10000
to 0xFFFFF
). This differentiates them from the related class TText
, which can only be used for 16-bit Unicode character values.
TChar
- Holds a character value and provides
a number of utility functions to manipulate it and test its properties.
TCharF
- Folds a specified character and
provides functions to fold additional characters after construction
of the object.
TCharLC
- Converts a specified character
to lower case and provides functions to convert additional characters
after construction of the object.
TCharUC
- Converts a specified character
to upper case and provides functions to convert additional characters
after construction of the object.
Click on the following link to download the example: tcharexample.zip.
click: browse to view the example code.
Using TChar
The example retrieves information about a character using:
various Is...()
functions, for instance its case (e.g. TChar::IsLower()
), whether it is alphabetic (TChar::IsAlpha()
), a decimal digit (TChar::IsDigit()
), and whether
it is printable (TChar::IsPrint()
).
various Get...()
functions, for instance its upper, lower and title
case versions, e.g. (TChar::GetUpperCase()
), and
the character width for Chinese, Japanese and Korean characters (TChar::GetCjkWidth()
).
the TChar::TCharInfo
struct. This struct holds most of the
information about the character, including its Unicode category, and
is populated by calling TChar::GetInfo()
.
Using TCharF, TCharLC and TCharUC
Related APIs
TChar::TCharInfo
- A structure to hold information
about a Unicode character.
TCharF
represents a folded character.
The example demonstrates how folding a character removes case and
accent distinctions.
The example also demonstrates converting
characters between lower and upper case using TCharLC
and TCharUC
.
To build the example:
You can build the example from your IDE or the command line.
If you use
an IDE, import the bld.inf
file of the example
into your IDE, and use the build command of the IDE.
If you use the command line, open a command prompt, and set the current directory to the source code directory of the example. You can then build the example with the SBSv1 build tools with the following commands:
bldmake bldfiles
abld build
For the emulator,
the example builds an executable called tcharexample.exe
in the epoc32\release\winscw\<udeb or
urel>\
folder.
The example application displays a list of options and sub options to the user and takes input from the user.