Names specified here
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_COLLATE. 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_COLLATE, 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.


CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2022-06-17T21:43:05.000+0000