Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Thursday, June 13, 2019
 
 

strcoll_l(3C)

Name

strcoll, strcoll_l - string collation

Synopsis

#include <string.h>

int strcoll(const char *s1, const char *s2);
int strcoll_l(const char *s1, const char *s2, locale_t locale);

Description

Both strcoll() and strxfrm(3C) provide for locale-specific string sorting. strcoll() is intended for applications in which the number of comparisons per string is small. When strings are to be compared a number of times, strxfrm(3C) is a more appropriate function because the transformation process occurs only once. Same applies between strcoll_l() and strxfrm_l(3C).

The strcoll() and strcoll_l() functions compare the string pointed to by s1 to the string pointed to by s2, both interpreted as appropriate to the LC_COLLATE category of the current locale, or of the locale represented by locale, respectively.

The strcoll() and strcoll_l() functions do not change the setting of errno if successful.

Since no return value is reserved to indicate an error, an application wishing to check for error situations should set errno to 0, then call strcoll() or strcoll_l(), then check errno.

The behavior is undefined if the <locale> argument to strcoll_l() is the special locale object LC_GLOBAL_LOCALE or is not a valid locale object handle.

Return Values

Upon successful completion, strcoll() and strcoll_l() return an integer greater than, equal to, or less than zero in direct correlation to whether string s1 is greater than, equal to, or less than the string s2. The comparison is based on strings interpreted as appropriate to the current locale or locale represented by locale respectively, for category LC_COLLATE (see setlocale(3C)).

On error, strcoll() and strcoll_l() may set errno, but no return value is reserved to indicate an error.

Errors

The strcoll() and strcoll_l() function may fail if:

EINVAL

The s1 or s2 arguments contain characters outside the domain of the collating sequence.

Files

/usr/lib/locale/locale/locale.so.*

LC_COLLATE database for locale

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
CSI
Enabled
Interface Stability
Committed
MT-Level
MT-Safe
Standard

See Also

wsxfrm(3C), localedef(1), duplocale(3C), freelocale(3C), newlocale(3C), setlocale(3C), string(3C), strxfrm(3C), uselocale(3C), attributes(7), environ(7), standards(7)