towlower() – towupper() — Convert Wide Character Case
Format
#include <wctype.h>
wint_t towlower(wint_t wc);
wint_t towupper(wint_t wc);
Language Level
ANSI
Threadsafe
Yes
Locale Sensitive
The behavior of these functions might be affected by the LC_CTYPE category of the current locale if LOCALETYPE(*LOCALE) is specified on the compilation command. The behavior of these functions might also be affected by the LC_UNI_CTYPE category of the current locale if either the LOCALETYPE(*LOCALEUCS2) or LOCALETYPE(*LOCALEUTF) option is specified on the compilation command. These functions are not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.
Wide Character Function
See Wide Characters for more information.
Description
The towupper()
function
converts the lowercase character wc to the
corresponding uppercase letter. The towlower()
function
converts the uppercase character wc to the
corresponding lowercase letter.
Return Value
If wc is
a wide character for which iswupper()
(or iswlower()
) is
true and there is a corresponding wide character for which iswlower()
(or iswupper()
) is
true, towlower()
(or towupper()
) returns
the corresponding wide character. Otherwise, the argument is returned
unchanged.
Example
towlower()
and towupper()
to
convert characters between 0 and 0x7f. #include <wctype.h>
#include <stdio.h>
int main(void)
{
wint_t w_ch;
for (w_ch = 0; w_ch <= 0xff; w_ch++) {
printf ("towupper : %#04x %#04x, ", w_ch, towupper(w_ch));
printf ("towlower : %#04x %#04x\n", w_ch, towlower(w_ch));
}
return 0;
}
/************************************************************************
The output should be similar to:
:
towupper : 0xc1 0xc1, towlower : 0xc1 0x81
towupper : 0xc2 0xc2, towlower : 0xc2 0x82
towupper : 0xc3 0xc3, towlower : 0xc3 0x83
towupper : 0xc4 0xc4, towlower : 0xc4 0x84
towupper : 0xc5 0xc5, towlower : 0xc5 0x85
:
towupper : 0x81 0xc1, towlower : 0x81 0x81
towupper : 0x82 0xc2, towlower : 0x82 0x82
towupper : 0x83 0xc3, towlower : 0x83 0x83
towupper : 0x84 0xc4, towlower : 0x84 0x84
towupper : 0x85 0xc5, towlower : 0x85 0x85
:
**********************************************************************/