strxfrm() — Transform String
Format
#include <string.h>
size_t strxfrm(char *string1, const char *string2, size_t count);
Language Level
ANSI
Threadsafe
Yes
Locale Sensitive
The behavior of this function might be affected by the LC_CTYPE and LC_COLLATE categories of the current locale. For more information, see Understanding CCSIDs and Locales.
Description
The strxfrm()
function
transforms the string pointed to by string2 and
places the result into the string pointed to by string1.
The transformation is determined by the program's current locale.
The transformed string is not necessarily readable, but can be used
with the strcmp()
or
the strncmp()
functions.
Return Value
The strxfrm()
function
returns the length of the transformed string, excluding the ending
null character. If the returned value is greater than or equal to count,
the contents of the transformed string are indeterminate.
If strxfrm()
is
unsuccessful, errno is changed. The value of errno may be set to
EINVAL (the string1 or string2 arguments
contain characters which are not available in the current locale).
Example
strxfrm()
to
transform the string and return its length. #include <stdio.h>
#include <string.h>
int main(void)
{
char *string1, buffer[80];
int length;
printf("Type in a string of characters.\n ");
string1 = gets(buffer);
length = strxfrm(NULL, string1, 0);
printf("You would need a %d element array to hold the string\n",length);
printf("\n\n%s\n\n transformed according",string1);
printf(" to this program's locale. \n");
}