COHERENT manpages

This page displays the COHERENT manpage for strxfrm() [Transform a string using locale information].

List of available manpages
Index


strxfrm() -- String Function (libc)

Transform a string using locale information
#include <string.h>
unsigned int strxfrm(string1, string2, n)
char *string1, *string2; unsigned int n;

strxfrm()  transforms string2  using information  concerning  the program's
locale, as set by the function setlocale(). It then writes up to n bytes of
the transformed  result into the area to which  string1 points.  It returns
the length  of the transformed  string, not including  the terminating null
character.  The  transformation incorporates locale-specific  material into
string1.

If  n is  set to  zero,  strxfrm() returns  the length  of the  transformed
string.

If  two strings  return a  given result when  compared by  strcoll() before
transformation, they will return  the same result when compared by strcmp()
after transformation.

Example

The following simple program demonstrates strxfrm():

#include <stdio.h>
#include <string.h>

main()
{
    char string1[20], string2[20];

    strcpy (string1, "This is string 1");
    strcpy (string2, "This is string 2");

    printf ("String 1 before transformation: %s\n", string1);
    printf ("String 2 before transformation: %s\n", string2);

    strxfrm (string1, string2, 18);

    printf ("String 1 after transformation: %s\n", string1);
    printf ("String 2 after transformation: %s\n", string2);
}

See Also

libc,
string.h
ANSI Standard, §7.11.4.5

Notes

If strxfrm()  returns a value equal  to or greater than  n, the contents of
the area to which string1 points are indeterminate.