ILE C/C++ Run-Time Library Functions


wcsxfrm() -- Transform a Wide-Character String

Format

#include <wchar.h>
size_t wcsxfrm (wchar_t *wcs1, const wchar_t *wcs2, size_t n);

Language Level: XPG4

Threadsafe: Yes.

Description

The wcsxfrm() function transforms the wide-character string pointed to by wcs2 to values which represent character collating weights and places the resulting wide-character string into the array pointed to by wcs1.

Note:
This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. The behavior of this wide-character function is affected by the LC_COLLATE category of the current locale, unless LOCALETYPE(*LOCALEUTF) was specified on the compilation command. If LOCALETYPE(*LOCALEUTF) was specified this function is affected by the LC_UNI_COLLATE category of the current locale.

Return Value

The wcsxfrm() function returns the length of the transformed wide-character string (not including the ending null wide character code). If the value returned is n or more, the contents of the array pointed to by wcs1 are indeterminate.

If wcsxfrm() is unsuccessful, errno is changed. The value of errno may be set to EINVAL (the wcs1 or wcs2 arguments contain characters which are not available in the current locale).

Example that uses wcsxfrm()


#include <stdio.h>
#include <wchar.h>
 
int main(void)
{
   wchar_t *wcs;
   wchar_t buffer[80];
   int length;
 
   printf("Type in a string of characters.\n ");
   wcs = fgetws(buffer, 80, stdin);
   length = wcsxfrm(NULL, wcs, 0);
   printf("You would need a %d element array to hold the wide string\n", length);
   printf("\n\n%S\n\n transformed according", wcs);
   printf(" to this program's locale. \n");
}

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]