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
Locale Sensitive
The behavior of this function might be affected by the LC_COLLATE category of the current locale if LOCALETYPE(*LOCALE) is specified on the compilation command. The behavior of this function might also be affected by the LC_UNI_COLLATE category of the current locale if LOCALETYPE(*LOCALEUTF) is specified on the compilation command. This function is not supported when LOCALETYPE(*LOCALEUCS2) is specified on the compilation command. This function is 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 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.
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
#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");
}