The C <ctype.h> islower test if the character is a lower case character(small letter).Which character is considered as lower case depends on the current locale setting.In “C” locale-the default locale set in the compiler-only the small letter [a,z] is considered as lower case.The declaration of the function is given below.
|int islower(int c);|
c -The character to be tested for lower case.
int -Returns non-zero value if the argument is lower case.
Note in “C” locale the return value of the ‘islower’ and ‘isupper’ functions is exclusive for any character.However,in other locale some characters may return true value by both the function.And also note for any character which ‘islower’ returns true none of the functions-iscntrl , isdigit , ispunct , or isspace is true.
The code example below in evaluated in “C” locale.
printf(“\n%d” , islower(‘n’));
printf(“\n%d” , islower(81)); //represent the character ‘Q’
printf(“\n%d” , islower( 113 )); //represent the character ‘q’
printf(“\n%d” , islower(‘\xe7’)); //represent the Turkish lower case character ‘ç’
Output in CB,
In passing the Turkish small letter ‘ç’ the function returns 0(false).In the next section we will set the locale to Turkish and once again let us examine the return value of ‘islower’.
Setting specific locale and examining the return value of islower
To can change the current locale by calling the function ‘setlocale’ and pass the first argument as “
LC_CTYPE” macro the second argument will depend on the locale you want to set.To set the locale to Turkish pass the string “trk_TUR.1254” or if you want to set the locale to German pass the string “deu_DEU.1252“,to know which string to pass for any other locale check your compiler documentation.Ok then lets examine the code below.
printf(“%d” , islower(‘\xE7’)); //represent the Turkish lower case character ‘ç’
printf(“\n%d” , islower(‘\xC7’)); //represent the Turkish upper case character ‘Ç’
printf(“\n%d” , islower(‘A’));
printf(“\n%d” , islower(‘\xFC’)); //Represent the small letter ‘ü’
Now for the small letter ‘ç’ and ‘ü’ the function returns true but for the two other character which is a Turkish upper case letter the return value is false.