Name

towctrans

Synopsis

Performs a locale-specific conversion on a wide character

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

The towctrans() function returns a wide character that corresponds to the wide character value of its first argument, wc, according to a locale-specific mapping described by the second argument, desc. Values of desc are obtained by calling the wctrans() function. The behavior of both wctrans() and towctrans() is dependent on the locale setting of the category LC_CTYPE, which must not change between the two function calls.

Example

wint_t before = L'\0', after = L'\0';
wctrans_t mapping;
mapping = wctrans("toupper");

while (( before = getwchar() ) != WEOF )
{
  after = towctrans( before, mapping );
  putwchar( after );
  if ( after == L'Q' )
    break;
}

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.