Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strxfrm - string transformation based on LC_COLLATE

&pagelevel(4)&pagelevel

Syntax

#include <string.h>

size_t strxfrm(char *s1, const char *s2, size_t n);

Description

strxfrm() transforms the string s2 and places the resulting string into the array s1. The
transformation is such that if strcmp() were applied to two transformed strings, it would
return a value corresponding to the result of strcoll() applied to the same two original
strings. The transformation is based on the collating sequence defined by the local setting
of the program ́s LC_COLLATE category (see setlocale()).

A maximum of n bytes are placed into the resulting array pointed to by s1, including the
terminating null byte. If n is 0, s1 is permitted to be a null pointer. If copying takes place
between objects that overlap, the behavior is undefined.

Return val.

Length of the transformed string (excluding the terminating null byte)



if successful.

Return val.

Value ≥ n

The contents of the array s1 are indeterminate.


Since no return value is reserved to indicate an error, errors can only be detected as follows:
by setting errno to 0, calling the strxfrm() function, and then checking errno after the
function returns. If errno is non-zero, it may be assumed that an error occurred.

Errors

strxfrm() will fail if:

EINVAL

The s2 argument contains characters outside the domain of the collating
sequence.

Notes

A string terminated with the null byte (\0) is expected as argument s2.

String s2 is not modified by strxfrm(). The transformation is performed in a work area.

If the return value is greater than or equal to n, the contents of string s1 will be indeterminate,
since no null byte was written.

If the hexadecimal value 0 has been assigned to one of the characters in string s2 in the
current locale, the transformed string will be terminated using that character as the null
byte.

See also

setlocale(), strcoll(), strcmp(), string.h.