Internationalizing and Localizing Applications in Oracle Solaris

Exit Print View

Updated: July 2014
 
 

Character Transliteration Functions

The following functions serve for mapping characters between character classes (character transliteration). If a mapping for a character is in the character class of the current locale, the functions return a transliterated character. These functions are locale sensitive.

tolower()

Convert an uppercase character to lowercase

toupper()

Convert a lowercase character to uppercase

towlower()

Convert an uppercase wide character to lowercase

towupper()

Convert a lowercase wide character to uppercase

The following functions provide a generic way to perform character transliteration:

wctrans()

Define character mapping

towctrans()

Wide-character mapping

For more information about related functions for Unicode strings, see Processing UTF-8 Strings.

Example 2-12  Transliteration of a Wide Character

The following code fragment shows how to use the towupper() function for transliterating a Unicode wide character to uppercase.

  wint_t  wc;
  int     ret;

  setlocale(LC_ALL, "cs_CZ.UTF-8");

  /* "\xc5\x99" is UTF-8 for LATIN SMALL LETTER R WITH CARON */
  ret = mbtowc(&wc, "\xc5\x99", 2);
  if (ret == (size_t)-1) {
          /* Invalid character sequence. */
          :
  }

  wprintf(L"'%c' is uppercase of '%c'.\n", towupper(wc), wc);

The example will produce the following output:

Ř is uppercase of ř.