6.23.56 wcsxfrm Function
Transforms a wide string based on locale.
Include
<wchar.h>
Prototype
size_t wcsxfrm( wchar_t * restrict s1, const wchar_t * restrict s2,
size_t n);
Arguments
s1
- the array to hold the transformed wide string
s2
- the wide string to transform
n
- the maximum number of wide characters to transform
Return Value
The function returns the length of the transformed wide string (not including the terminating
null wide character). If the value returned is n
or greater, the contents of
the array pointed to by s1
are indeterminate.
Remarks
The function transforms the wide string pointed by s2
according to the
current locale and places no more than n
wide characters of the result and a
terminating null wide character into the array pointed to by s1
. A null
pointer may be specified for s1
if n
is zero, in which case
the function can be used to obtain the size of the transformed wide string.
Example
#include <wchar.h>
#include <stdio.h>
int main(void)
{
wchar_t * wcs;
wchar_t buffer[40];
int length;
printf("Enter a wide string\n");
wcs = fgetws(buffer, 40, stdin);
length = wcsxfrm(NULL, wcs, 0);
printf("string length once transformed to current locale: %d\n", length);
}
Example Output
The output of this program might vary based on the LC_COLLATE
category of the
current locale.