### towctrans -- Perform Wide-Character Mapping

Format

>     #include <wctype.h>
>     wint_t towctrans(wint_t wc, wctrans_t desc);

Language Level: ANSI 93
towctrans maps the wide character wc using the mapping described by desc. The current setting of the LC_CTYPE category shall be the same as the one used during the call to towctrans that returned the value desc.

Each of the following two expressions behaves the same as the call to the wide-character case-mapping function in the comment that follows the expression:

>     towctrans(wc, wctrans("tolower"))    /* towlower(wc) */
>     towctrans(wc, wctrans("toupper"))    /* towupper(wc) */

Return Value
towctrans returns the mapped value of wc using the mapping described by desc.

Example
This example translates the lower case alphabet to upper case, and back to lower case.

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <wchar.h>
    #include <wctype.h>

    int main()
    {
       char *alpha = "abcdefghijklmnopqrstuvwxyz";
       char *tocase[2] = {"toupper", "tolower"};
       wchar_t *wcalpha;
       int i, j;
       size_t alphalen;

       alphalen = strlen(alpha)+1;
       wcalpha = (wchar_t *)malloc(sizeof(wchar_t)*alphalen);

       mbstowcs(wcalpha, alpha, 2*alphalen);

       for (i=0; i<2; ++i) {
          printf("Input string: %ls\n", wcalpha);
          for (j=0; j<strlen(alpha); ++j) {
             wcalpha[j] = (wchar_t)towctrans((wint_t)wcalpha[j], wctrans(tocase[i]));
          }
          printf("Output string: %ls\n", wcalpha);
          printf("\n");
       }
       return 0;

       /*************************************************************************
          The output should be similar to:

          Input string: abcdefghijklmnopqrstuvwxyz
          Output string: ABCDEFGHIJKLMNOPQRSTUVWXYZ

          Input string: ABCDEFGHIJKLMNOPQRSTUVWXYZ
          Output string: abcdefghijklmnopqrstuvwxyz
       *************************************************************************/
    }

wctrans -- Get Handle for Character Mapping
<wchar.h>