wctype.h File Reference

Typedef wctrans_t

typedef intwctrans_t

A scalar type that can hold values which represent locale-specific character mappings.

_WCTRANS_T

Typedef wctype_t

typedef unsigned longwctype_t

A scalar type of a data object that can hold values which represent locale-specific character classification.

_WCTYPE_T

Typedef wint_t

typedef __wint_t wint_t

_WINT_T_DECLARED

WEOF

iswalnum ( wint_t )

IMPORT_C intiswalnum(wint_t)

The iswalnum() function tests whether 'i' is a wide alphabet or wide digit i.e. it belongs to class alnum(see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class alnum, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswalnum()
#include<stdio.h>  //printf()
void test_iswalnum()
{
   int arr[]={'8',0xe1,'5','Z',0xfd,0xFF12,0xFF19,0xFF71,0x03A3};
   int i = 0;
   int size = 9;
   for( i=0; i<size; i++)
   {
     int ret = iswalnum(arr[i]); //call to the API with chars in the arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide alnum", arr[i]);
     }
     else
     {
        printf("
%lc is a wide alnum ", arr[i]);
     }
   }
printf("
");
}
Output
8 is wide alnum
 is wide alnum
5 is wide alnum
Z is wide alnum
 is wide alnum
 is wide alnum
 is wide alnum
 is wide alnum
 is wide alnum

See also: isalnum() iswctype()

Return Value
The functions return non-zero if i is wide alphabet or wide digit and zero otherwise.

iswalpha ( wint_t )

IMPORT_C intiswalpha(wint_t)

The iswalpha() function tests whether 'i' is a wide alphabet i.e. it belongs to class alpha (see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class alpha, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswalpha()
#include<stdio.h>  //printf()
void test_iswalpha()
{
   int arr[]={'a',0xe1,'5','Z',0xfd, 0x3041,0xFF9D,0x009F,0x007E};
   int i = 0;
   int size = 9;
   for( i=0; i<size; i++)
   {
     int ret = iswalpha(arr[i]); //call to API with chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide alphabet", arr[i]);
     }
     else
     {
        printf("
%lc is wide alphabet", arr[i]);
     }
   }
printf("
");
}
Output
a is wide alphabet
 is wide alphabet
5 is not wide alphabet
Z is wide alphabet
 is wide alphabet
 is wide alphabet
 is wide alphabet
 is not wide alphabet
~ is not wide alphabet

See also: isalpha() iswctype()

Return Value
The functions return non-zero if 'i' is a wide alphabet and zero otherwise.

iswblank ( wint_t )

IMPORT_C intiswblank(wint_t)

The iswblank() function tests whether 'i' is a wide-character that belongs to the character class - blank (see defns for definition). The character class blank contains the character space('') and the horizontal tabulation(' ').

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class blank, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswblank()
#include<stdio.h> //printf()
int test_iswblank()
{
   int arr[]={0x0020,'0',0x0009,'R',0x3000, 0x000A, 0x002};
   int i = 0;
   int size = 7;
   for( i=0; i<size; i++)
   {
     int ret = iswblank(arr[i]); //call to the API with the chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide blank ", arr[i]);
     }
     else
     {
        printf("
%lc is wide blank", arr[i]);
     }
   }
printf("
");
}
Output
is wide blank
0 is not wide blank
     is wide blank
R is not wide blank
 is wide blank
 is not wide blank
 is not wide blank

See also: iswctype()

Return Value
The functions return non-zero if 'i' is wide blank character and zero otherwise.

iswcntrl ( wint_t )

IMPORT_C intiswcntrl(wint_t)

The iswcntrl() function tests whether 'i' is a wide control character i.e it belongs to class cntrl (see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class cntrl, irrespective of the locale they belong to.

The control characters are:

BELL

DELETE

BACKSPACE

LINE FEED

VERTICAL TABULATION

FORM FEED

CARRIAGE RETURN...and the like.

Examples:
#include<wctype.h> //iswcntrl()
#include<stdio.h> //printf()
int test_iswcntrl()
{
   int arr[]={0x7F,'9','A','$','\a'};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = iswcntrl(arr[i]); //call to API with chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide cntrl char ", arr[i]);
     }
     else
     {
        printf("
%lc is wide cntrl char", arr[i]);
     }
   }
printf("
");
}
Output
is wide cntrl char
9 is not wide cntrl char
A is not wide cntrl char
$ is not wide cntrl char
 is wide cntrl char

See also: iswcntrl() iswctype()

Return Value
The functions return non-zero if 'i' is a wide control character and returns zero otherwise.

iswctype ( wint_t, wctype_t )

IMPORT_C intiswctype(wint_t,
wctype_t
)

The iswctype() function tests whether the wide-character wch belongs to the character class/category chcl.

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the programs current locale and so it returns non-zero for all the characters given in wch(of various locales supported) that belong to the class chcl(see _ctype.h for definition of values that can be used to specify category), irrespective of the locale they belong to.

For example: digits 0 to 9 would belong to _CTYPE_D class (i.e. class digit), and a to z would belong to _CTYPE_L class (i.e. class lower).

Examples: Reimplement iswalpha in terms of iswctype and wctype :
int
myiswalpha(wint_t wc)
{
        return (iswctype(wc, wctype("alpha")));
}
#include <wchar.h>
/* Illustrates how to use wctype API */
wctype_t example_wctype()
{  
 wctype_t type;
 
  /* get the type by passing the operation string to the wctype API */
 type = wctype("alnum");
  
 /* if the operation is successful then it should return non-zero value */
 /* else returns 0 */
  return type;
}

Limitations:

The current implementation of iswctype and wctype is dependent on the locale support of Symbian OS. It doesn't work for the locales which the Symbian OS

Parameters
Note: This description also covers the following functions - wctype()
Return Value
The iswctype function returns non-zero if, and only if, wc has the property described by charclass , or charclass is zero. The wctype function returns 0 if property is invalid, otherwise it returns a value of type wctype_t that can be used in subsequent calls to iswctype .

iswdigit ( wint_t )

IMPORT_C intiswdigit(wint_t)

The iswdigit() function tests whether 'i' is a wide digit. The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class digit(see defns for definition), irrespective of the locale they belong to.

For example, the digits 0 to 9 fall under class digit.

Examples:
#include<wctype.h> //iswdigit()
#include<stdio.h> //printf()
void test_iswdigit()
{
   int arr[]={'8',0xe1,'5','Z',0xfd,
   0xFF12,0xFF19,0xFF71,0x03A3};
   int i = 0;
   int size = 9;
   for( i=0; i<size; i++)
   {
     int ret = iswdigit(arr[i]); //call to the API with chars in arr[]
     if( (!ret) != 0 )
     {
         printf("
%lc is not a wide digit", arr[i]);
     }
     else
     {
         printf("
%lc is a wide digit", arr[i]);
     }
   }
printf("
");
}
Output
8 is wide digit
 is not wide digit
5 is wide digit
Z is not wide digit
 is not wide digit
 is wide digit
 is wide digit
  is not wide digit
  is not wide digit

See also: isdigit() iswctype()

Return Value
The functions return non-zero if 'i' is a wide digit and zero otherwise.

iswgraph ( wint_t )

IMPORT_C intiswgraph(wint_t)

The iswgraph() function tests whether 'wch' is a visible wide-character i.e it belongs to class graph (see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class graph, irrespective of the locale they belong to.

Examples:
#include<wctype.h>
#include<stdio.h>
int test_iswgraph()
{
   int arr[]={'n','\f', 0xe1, '6', ' '};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = iswgraph(arr[i]);
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide visible char ", arr[i]);
     }
     else
     {
        printf("
%lc is wide visible char", arr[i]);
     }
   }
printf("
");
}
Output
n is wide visible char
 is not wide visible char
 is wide visible char
6 is wide visible char
  is not wide visible char

See also: isgraph() iswctype()

Return Value
The function returns non-zero if 'i' has visual representation and zero otherwise.

iswlower ( wint_t )

IMPORT_C intiswlower(wint_t)

The iswlower() function tests whether 'i' is a wide-character which is from among lower-case alphabets.

Characters that belong to class cntrl, class punct and digit are not a part of class lower (see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class lower(see defns for definition), irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswlower()
#include<stdio.h> //printf()
int test_iswlower()
{
   int arr[]={ 0x0126, 0xee, 'r' , '9' , 'g', 0xFF51, 0x0451, 0x03CE };
   int i = 0;
   int size = 8;
   for( i=0; i<size; i++)
   {
     int ret = iswlower(arr[i]); //call to the API with chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide lower-case ", arr[i]);
     }
     else
     {
        printf("
%lc is wide lower-case", arr[i]);
     }
   }
printf("
");
}
Output
 is not wide lower-case
 is wide lower-case
r is wide lower-case
9 is not wide lower-case
g is wide lower-case
 is wide lower-case
 is wide lower-case
 is wide lower-case

See also: islower() iswctype()

Return Value
The function returns non-zero if 'i' is wide lower-case and zero otherwise.

iswprint ( wint_t )

IMPORT_C intiswprint(wint_t)

The iswprint() function tests whether 'i' is a wide-character that can be printed i.e it belongs to class print (see defns for definition).

Characters used for representing the alphabets, digits, punctuation characters and space are classified as printable. No characters under class cntrl are printable.

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class print, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswprint()
#include<stdio.h> //printf()
int test_iswprint()
{
   int arr[]={'n',', 0xe1, '6', ' '};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = iswprint(arr[i]); //call to the API with chars in the arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide printable char ", arr[i]);
     }
     else
     {
        printf("
%lc is wide printable char", arr[i]);
     }
   }
printf("
");
}
Output
n is wide printable char
 is not wide printable char
 is wide printable char
6 is wide printable char
  is wide printable char

See also: isprint() iswctype()

Return Value
The function returns non-zero if the wide character is printable and returns zero otherwise.

iswpunct ( wint_t )

IMPORT_C intiswpunct(wint_t)

The iswpunct() function tests whether 'wch' can be classfied wide punctuation character i.e. it belongs to class punct (see defns for definition)

The characters that can be classified as alphabets, digits, space or control characters do not belong to punctuation wide-character code.

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class punct, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswpunct()
#include<stdio.h>  //printf()
int test_iswpunct()
{
 
   int arr[]={0x3003,'3',0x301C,'*', '+'};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = iswpunct(arr[i]);//call to the API with chars in arr[]
     if( (!ret) != 0 )
     {
         printf("
0x%x is not wide punc char ", arr[i]);
     }
     else
     {
         printf("
0x%x is a wide punc char", arr[i]);
     }
   }
printf("
");
}
Output
0x3003 is a wide punc char
0 0x33 is not  wide punc char
0x301c is a wide punc char
0x2a is a wide punc char
0x2b is a wide punc char

See also: ispunct() iswctype()

Return Value
The function returns non-zero if 'wch' is a wide character and returns zero otherwise.

iswspace ( wint_t )

IMPORT_C intiswspace(wint_t)

The iswspace() function tests whether 'i' is a wide-character that introduces white-space (see defns for definition)

The following are such characters in the POSIX locale:

SPACE

FORM-FEED

NEWLINE

CARRIAGE-RETURN

TAB

VERTICAL-TAB

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class space, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswspace()
#include<stdio.h> //printf()
int test_iswspace()
{
   int arr[]={'\n','0','w','R',0x3000,' ', 0x000A, 0x002};
   int i = 0;
   int size = 8;
   for( i=0; i<size; i++)
   {
     int ret = iswspace(arr[i]); //call to the API with chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide space ", arr[i]);
     }
     else
     {
        printf("
%lc is wide space", arr[i]);
     }
   }
printf("
");
}
Output
is wide space
0 is not wide space
w is not wide space
R is not wide space
 is wide space
  is wide space
 is wide space
 is wide space

See also: isspace() iswctype()

Return Value
The functions return zero if the character tests false and return non-zero if the character tests true.

iswupper ( wint_t )

IMPORT_C intiswupper(wint_t)

The iswupper() function tests whether wch is a wide-character that belongs to upper-case letters, i.e. checks if it belongs to class upper (see defns for definition).

Characters that belong to class cntrl, punct and digit are not a part of class upper(see defns for definition).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class upper, irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswupper()
#include<stdio.h>  //printf()
int test_iswupper()
{
   int arr[]={'8',0xe1,'5','Z',0x0126 , 0xFF21 ,'G' , 0x03A4 , 0x00CF };
   int i = 0;
   int size = 9;
   for( i=0; i<size; i++)
   {
     int ret = iswupper(arr[i]); //call to the API with the chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%lc is not wide upper-case ", arr[i]);
     }
     else
     {
        printf("
%lc is wide upper-case", arr[i]);
     }
   }
printf("
");
}
Output
8 is not wide upper-case  is not wide upper-case
5 is not wide upper-case
Z is wide upper-case
 is wide upper-case
 is wide upper-case
G is wide upper-case
 is wide upper-case
 is wide upper-case

See also: isupper() iswctype()

Return Value
The functions return zero if the character tests false and return non-zero if the character tests true.

iswxdigit ( wint_t )

IMPORT_C intiswxdigit(wint_t)

The iswxdigit() function tests whether 'i' is a wide-character belongs to the set of characters that are used to represent hexadecimal digits.

For example: The characters that can be used to represent hexadecimal values: are - 0,1,2,3,4,5,6,7,8,9 and a,b,c,d,e,f and A,B,C,D,E,F.

Generally, the characters that can be classified as digits are used for the representing hexadecimal values along with one or more sets of continuous characters of other categories that are used to represent the hexadecimal values other than the digits(base 10).

The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.

The functionality of this API is independent of the program's current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class xdigit (see defns for definition), irrespective of the locale they belong to.

Examples:
#include<wctype.h> //iswxdigit()
#include<stdio.h> //printf()
int test_iswxdigit()
{
   int arr[]={'F','a','M','9','2'};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = iswxdigit(arr[i]); //call to the API with the chars in arr[]
     if( (!ret) != 0 )
     {
        printf("
%c is not wide hex-digit ", arr[i]);
     }
     else
     {
        printf("
%c is wide hex-digit", arr[i]);
     }
   }
printf("
");
}
Output
F is wide hex-digit
a is wide hex-digit
M is not wide hex-digit
9 is wide hex-digit
2 is wide hex-digit

See also: isdigit() iswctype()

Return Value
The functions return zero if the character tests false and return non-zero if the character tests true.

towctrans ( wint_t, wctrans_t )

IMPORT_C wint_ttowctrans(wint_t,
wctrans_t
)

The wctrans function returns a value of type wctrans_t which represents the requested wide character mapping operation and may be used as the second argument for calls to towctrans .

The following character mapping names are recognised:

 tolower	toupper

The towctrans function transliterates the wide character wc according to the mapping described by desc .

The behavior of the wctrans and towtrans is affected by LC_CTYPE category of the current locale.

Examples:
#include <wchar.h>
/* Illustrates how to use wctrans API */
wctrans_t example_wctrans()
{  
  wctrans_t type;
 
  /* get the type by passing the operation string to the wctrans API */
 type = wctrans("alnum");
  
 /* if the operation is successful then it should return non-zero value else returns 0 */
  return type;
}
#include <wchar.h>
#include <wctype.h>
/* Illustrates how to use towctrans API */
TInt example_towctrans(void)
{ 
 wctrans_t type;
 /* get the type by passing the string */  
 type = wctrans("tolower");
  
 /* if the type is 0 then return an error, else call the API to translate */
 if(type == (wctype_t)0)
  return -1;
  /* translate the input char to specified type */
 wint_t twc = towctrans(L'K',type);
 /* return no error if conversion is ok else return error */  
 if(twc != (wint_t)L'k')
   return -1;
  
  return 1;
}

Limitations:

The current implementation of wctrans and towtrans is dependent on the locale support of Symbian OS. It doesn't work for the locales which the Symbian OS doesn't support.

See also: tolower() toupper() wctype()

Parameters
Note: This description also covers the following functions - wctrans()
Return Value
The towctrans function returns the transliterated character if successful, otherwise it returns the character unchanged and sets errno . The wctrans function returns non-zero if successful, otherwise it returns zero and sets errno .

towlower ( wint_t )

IMPORT_C wint_ttowlower(wint_t)

The towlower function converts an upper-case letter to the corresponding lower-case letter.

The behavior of the towlower is affected by LC_CTYPE category of the current locale.

Examples:
#include <wchar.h>
/* Illustrates how to use towlower API */
wint_t example_towlower(void)
{ 
 /* input character */
  wint_t uwc = L'M'; 
  wint_t lwc;
  /* convert a wide char from upper case to lower case */
  lwc = towlower(uwc);
 
 /* return the converted char or error if not */
  return lwc;
}

Limitations:

The current implementation of towlower is dependent on the locale and works only for locales supported by Symbian OS.

See also: iswlower() tolower() towupper() wctrans()

Return Value
If the argument is an upper-case letter, the towlower function returns the corresponding lower-case letter if there is one; otherwise the argument is returned unchanged.

towupper ( wint_t )

IMPORT_C wint_ttowupper(wint_t)

The towupper function converts a lower-case letter to the corresponding upper-case letter.

The behavior of the towupper is affected by LC_CTYPE category of the current locale.

Examples:
#include <wchar.h>
/* Illustrates how to use towupper API */
wint_t example_towupper(void)
{ 
 /* input character */
  wint_t lwc = L'm'; 
  wint_t uwc;
  /* convert a wide char from lower case to upper case */
  uwc = towupper(lwc);
 
 /* return the converted char or error if not */
  return uwc;
}

Limitations:

The current implementation of towupper is dependent on the locale and works only for locales supported by Symbian OS.

See also: iswupper() toupper() towlower() wctrans()

Return Value
If the argument is a lower-case letter, the towupper function returns the corresponding upper-case letter if there is one; otherwise the argument is returned unchanged.

wctrans ( const char * )

IMPORT_C wctrans_twctrans(const char *)
Parameters
Refer to towctrans() for the documentation

wctype ( const char * )

IMPORT_C wctype_twctype(const char *)

Parameters
Refer to iswctype() for the documentation