Name | Description | Notes | Source | Availability | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
strcoll() |
Compare string | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
strxfrm() |
Transform string | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
wcscoll() |
Compare wide-character string | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wcsxfrm() |
Transform wide-character string | (·) | <wchar.h> |
C95 | C99 | C11 |
#include <string.h>
int strcoll(const char *s1, const char *s2);
size_t strxfrm(char *dst, const char *src, size_t n);
#include <wchar.h>
int wcscoll(const wchar_t *s1, const wchar_t *s2);
size_t wcsxfrm(wchar_t *dst, const wchar_t *src, size_t n);
strcoll
and wcscoll
compare two null-terminated strings s1
and s2
of bytes or wide
characters respectively. The return value indicates a
relative ordering of the two strings. Positive indicates that
s1
‘comes after’ s2
, negative indicates that s2
comes after s1
, and zero
indicates that the strings have equal position.
The comparison is influenced by the locale category
LC_
. This might, for example,
compare letters case-insensitively, or treat compound letters
like ß
as their expansions,
e.g.,
ss
.
For a simpler element-by-element comparison, see
strcmp
and wcscmp
.
The functions strxfrm
and wcsxfrm
transform the null-terminated string src
according to the locale category LC_
, and write the
transformed string into dst
, returning
its length (which excludes the terminating null character).
The result is such that applying strcmp
or wcscmp
to two such transformed strings
yields the same result as applying strcoll
or wcscoll
to the two original strings.
If dst
is NULL
, the transformation
is performed, but no characters are written. This means that
an expression such as 1 + strxfrm(NULL, src, 0)
yields the size
of the array required to store the transformed string.