function
<cwctype>
towctrans
wint_t towctrans(wint_t c, wctrans_t desc);
Convert using transformation
Applies a the transformation specified by desc to the wide character c.
A specific locale can accept multiple transformations for characters. At least the following transformations are recognized by all locales:
The setting of the LC_CTYPE locale category at the time of calling the function shall be the same as when wctrans was called to obtain desc.
Parameters
- c
- Wide character to be transformed, casted to a wint_t value, or WEOF.
wint_t is an integral type.
- desc
- A value returned by a call to wctrans (with the same LC_CTYPE locale category selected as in this call).
wctrans_t is the scalar type used as return type for wctrans.
Return Value
The character transformation of c, if such value exists, or c (unchanged) otherwise.
The value is returned as a wint_t value that can be implicitly casted to wchar_t.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
/* towctrans example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
int i=0;
wchar_t str[] = L"Test String.\n";
wchar_t c;
wctype_t check = wctype("lower");
wctrans_t trans = wctrans("toupper");
while (str[i])
{
c = str[i];
if (iswctype(c,check)) c = towctrans(c,trans);
putwchar (c);
i++;
}
return 0;
}
|
Output:
See also
- wctrans
- Return character transformation (function)
- towupper
- Convert lowercase wide character to uppercase (function)
- towlower
- Convert uppercase wide character to lowercase (function)
- iswctype
- Check if wide character has property (function)