|
||
_tolower (c) ((c) + 0x20)
This macro always expect that the argument sent is always in uppercase and works only with c locale. else the behavior is undefined
|
_toupper (c) ((c) - 0x20)
This macro always expect that the argument sent is always in lowercase and works only with c locale. else the behavior is undefined
|
Interface status: | externallyDefinedApi |
IMPORT_C int isalnum(int);
The function isalnum returns non-zero if 'c' is alphanumeric i.e. it belongs to class alnum(see defns for definition). In other words, it returns non-zero if the test for isalpha or isdigit is non-zero, irrespective of the program's current locale. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //isalnum()
#include<stdio.h> //printf()
void test_isalnum()
{
int arr[]={'8',0xe1,'5','Z',0xfd};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isalnum(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not alphanumeric", arr[i]);
}
else
{
printf("
%c is an alphanumeric ", arr[i]);
}
}
printf("
");
}
Output
a is an alphanumeric
á is an alphanumeric
5 is an alphanumeric
Z is an alphanumeric
ý is an alphanumeric
|
|
isalpha(int)
isalpha(int)
Test for an alphabetic character. For Unicode, the function returns TRUE for all...isdigit(int)
isdigit(int)
Tests whether the character is a standard decimal digit. For Unicode, this funct...iswalnum(wint_t)
iswalnum(wint_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int isalpha(int);
The isalpha function returns non-zero if 'c' is an alphabet i.e. it belongs to class alpha (see defns for definition). In other words, it returns non-zero if the test for isupper or islower is non-zero,irrespective of the program's current locale. The function will return non-zero for also those characters that are alphabets and cannot be categorised as upper or lower case. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //isalpha()
#include<stdio.h> //printf()
void test_isalpha()
{
int arr[]={'a',0xe1,'5','Z',0xfd};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isalpha(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not an alphabet", arr[i]);
}
else
{
printf("
%c is an alphabet", arr[i]);
}
}
printf("
");
}
Output
a is an alphabet
á is an alphabet
5 is not an alphabet
Z is an alphabet
ý is an alphabet
|
|
islower(int)
islower(int)
Tests if character is a lowercase letter. isupper(int)
isupper(int)
Tests whether the character is uppercase. iswalpha(wint_t)
iswalpha(wint_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int iscntrl(int);
The iscntrl function tests if 'c' is a control character i.e. it belongs to class cntrl(see defns for definition). For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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.
Examples:
#include<ctype.h> //iscntrl()
#include<stdio.h> //printf()
int test_iscntrl()
{
int arr[]={0x7F,’9’,’A’,’$’,’\a’ };
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = iscntrl(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not cntrl char ", arr[i]);
}
else
{
printf("
%c is cntrl char", arr[i]);
}
}
printf("
");
}
Output
is cntrl char
9 is not cntrl char
A is not cntrl char
$ is not cntrl char
is cntrl char
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int isdigit(int);
The isdigit function tests if ’c’ is a decimal digit character. Regardless of locale, this includes the following characters only:
‘‘0’’ ‘‘1’’ ‘‘2’’ ‘‘3’’ ‘‘4’’
‘‘5’’ ‘‘6’’ ‘‘7’’ ‘‘8’’ ‘‘9’’
Examples:
#include<ctype.h> //isdigit()
#include<stdio.h> //printf()
void test_isdigit()
{
int arr[]={'8',0xe1,'5','Z',0xfd};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isdigit(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not a digit", arr[i]);
}
else
{
printf("
%c is a digit", arr[i]);
}
}
printf("
");
}
Output
8 is a digit
á is not a digit
5 is a digit
Z is not a digit
ý is not a digit
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int isgraph(int);
The isgraph function returns non-zero if 'c' has visible representation i.e. it belongs to class graph(see defns for definition). It does not consider characters classified under class space and class cntrl (see defns for definition). For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //isgraph()
#include<stdio.h> //printf()
int test_isgraph()
{
int arr[]={’n’,’\f’, ’6’, ’ ’};
int i = 0;
int size = 4;
for( i=0; i<size; i++)
{
int ret = isgraph(arr[i]); //call to API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not visible char ", arr[i]);
}
else
{
printf("
%c is visible char", arr[i]);
}
}
printf("
");
}
Output
n is visible char
is not visible char
6 is visible char
is not visible char
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int islower(int);
The islower function tests if 'c' belongs to the set of lower-case letters i.e. it belongs to class lower(see defns for definition). For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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, irrespective of the locale they belong to.
Examples:
#include<ctype.h> //islower()
#include<stdio.h> //printf()
int test_islower()
{
int arr[]={0x0126,0xee,'r','9','g'};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = islower(arr[i]); //call to the API with chars in the arr[]
if( (!ret) != 0 )
{
printf("
%c is not in lower-case ", arr[i]);
}
else
{
printf("
%c is in lower-case", arr[i]);
}
}
printf("
");
}
Output
& is not in lower-case
î is in lower-case
r is in lower-case
9 is not in lower-case
g is in lower-case
|
|
iswlower(wint_t)
iswlower(wint_t)
...tolower(int)
tolower(int)
Tests whether the character is lowercase. Interface status: | externallyDefinedApi |
IMPORT_C int isprint(int);
The isprint function returns true if 'c' is a printable character. It considers characters under class space, but characters falling under class cntrl will not be considered(see defns for definition of these classes).
For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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(see defns for definition), irrespective of the locale they belong to.
Examples:
#include<ctype.h> //isprint()
#include<stdio.h> //printf()
int test_isprint()
{
int arr[]={’n’,’\f’, 0xe1, ’6’, ’ ’};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isprint(arr[i]); //call to the API with the chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not printable char ", arr[i]);
}
else
{
printf("
%c is printable char", arr[i]);
}
}
printf("
");
}
Output
n is printable char
is not printable char
á is not printable char
6 is printable char
is printable char
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int ispunct(int);
The ispunct function tests if 'c' is a punctuation character i.e. it belongs to class punct(see defns for definition). Characters under class space or a character for which isalnum is true(non-zero) are excluded. In other words, it tests for punctuation characters. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //ispunct()
#include<stdio.h> //printf()
int test_ispunct()
{
int arr[]={0x3003,'3',0x301C,'*', '+'};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = ispunct(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
0x%x is not a punc char ", arr[i]);
}
else
{
printf("
0x%x is a punc char", arr[i]);
}
}
printf("
");
return 0;
}
Output
0x3003 is a punc char
0x33 is not a punc char
0x301c is a punc char
0x2a is a punc char
0x2b is a punc char
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int isspace(int);
The isspace function tests if 'c' is from among white-space characters i.e. it belongs to class space(see defns for definition). This includes the following standard characters:
SPACE
FORM-FEED
NEWLINE
CARRIAGE-RETURN
TAB
VERTICAL-TAB
For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //isspace()
#include<stdio.h> //printf()
int test_isspace()
{
int arr[]={'
','0','w','R',0x3000,' '};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isspace(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not space char ", arr[i]);
}
else
{
printf("
%c is space char", arr[i]);
}
}
printf("
");
}
Output
is space char
0 is not space char
w is not space char
R is not space char
is space char
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int isupper(int);
The isupper function tests if 'c' is an upper-case alphabet i.e. it belongs to class upper(see defns for definition). For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.
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<ctype.h> //isupper()
#include<stdio.h> //printf()
int test_isupper()
{
int arr[]={0x0126,'G','7','B',0x3041};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isupper(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not in upper-case ", arr[i]);
}
else
{
printf("
%c is in upper-case", arr[i]);
}
}
printf("
");
}
Output
& is in upper-case
G is in upper-case
7 is not in upper-case
B is in upper-case
A is in upper-case
|
|
iswupper(wint_t)
iswupper(wint_t)
...toupper(int)
toupper(int)
Returns the character value after conversion to uppercase or the character's own...Interface status: | externallyDefinedApi |
IMPORT_C int isxdigit(int);
The isxdigit function tests if ’c’ is a hexadecimal-digit character. Regardless of locale, this includes the following characters only:
‘‘0’’ ‘‘1’’ ‘‘2’’ ‘‘3’’ ‘‘4’’
‘‘5’’ ‘‘6’’ ‘‘7’’ ‘‘8’’ ‘‘9’’
‘‘A’’ ‘‘B’’ ‘‘C’’ ‘‘D’’ ‘‘E’’
‘‘F’’ ‘‘a’’ ‘‘b’’ ‘‘c’’ ‘‘d’’
‘‘e’’ ‘‘f’’
Examples:
#include<ctype.h> //isxdigit()
#include<stdio.h> //printf()
int test_isxdigit()
{
int arr[]={'F','a','M','9','2'};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = isxdigit(arr[i]); //call to the API with chars in arr[]
if( (!ret) != 0 )
{
printf("
%c is not hex-digit ", arr[i]);
}
else
{
printf("
%c is hex-digit", arr[i]);
}
}
printf("
");
}
Output
F is hex-digit
a is hex-digit
M is not hex-digit
9 is hex-digit
2 is hex-digit
|
|
Interface status: | externallyDefinedApi |
IMPORT_C int tolower(int);
The tolower function converts an upper-case letter to the corresponding lower-case letter. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF .
The functionality of this API is independent of the program's current locale.
Examples:
#include<ctype.h> //tolower()
#include<stdio.h> //printf()
int test_tolower ()
{
struct st
{
int input;
int output;
};
struct st arr[]=
{
{ 'Q', 'q' },
{ 'g' , 'g' },
{ '9' , '9' },
{ '%' , '%' },
{ ' ' , ' ' },
};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = tolower(arr[i].input);//call to the API with the chars in the arr[]
if( ret != arr[i].output )
{
printf("
%c cannot convert ", arr[i].input);
}
else
{
printf("
%c ", arr[i].output);
}
}
printf("
");
}
Output
q
g
9
%
|
|
islower(int)
islower(int)
Tests if character is a lowercase letter. towlower(wint_t)
towlower(wint_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int toupper(int);
The toupper function converts a lower-case letter to the corresponding upper-case letter. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF . The functionality of this API is independent of the program's current locale.
Examples:
#include<ctype.h> //toupper()
#include<stdio.h> //printf()
int test_toupper()
{
struct st
{
int input;
int output;
};
struct st arr[]=
{
{ 'q', 'Q' },
{ 'G' , 'G' },
{ '9' , '9' },
{ '%' , '%' },
{ ' ' , ' ' },
};
int i = 0;
int size = 5;
for( i=0; i<size; i++)
{
int ret = toupper(arr[i].input);//call to the API with the chars in arr[]
if( ret != arr[i].output )
{
printf("
%c cannot convert ", arr[i].input);
}
else
{
printf("
%c ", arr[i].output);
}
}
printf("
");
}
Output
q
G
9
%
|
|
isupper(int)
isupper(int)
Tests whether the character is uppercase. towupper(wint_t)
towupper(wint_t)
...