1STRCOLL(3P)                POSIX Programmer's Manual               STRCOLL(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       strcoll, strcoll_l — string comparison using collating information
13

SYNOPSIS

15       #include <string.h>
16
17       int strcoll(const char *s1, const char *s2);
18       int strcoll_l(const char *s1, const char *s2,
19           locale_t locale);
20

DESCRIPTION

22       For strcoll(): The functionality described on this  reference  page  is
23       aligned  with the ISO C standard. Any conflict between the requirements
24       described here and the ISO C standard is unintentional. This volume  of
25       POSIX.1‐2017 defers to the ISO C standard.
26
27       The  strcoll()  and  strcoll_l()  functions  shall  compare  the string
28       pointed to by s1 to the string pointed to by s2,  both  interpreted  as
29       appropriate to the LC_COLLATE category of the current locale, or of the
30       locale represented by locale, respectively.
31
32       The strcoll() and strcoll_l() functions shall not change the setting of
33       errno if successful.
34
35       Since  no return value is reserved to indicate an error, an application
36       wishing to check for error situations should set errno to 0, then  call
37       strcoll(), or strcoll_l() then check errno.
38
39       The  behavior is undefined if the locale argument to strcoll_l() is the
40       special locale object LC_GLOBAL_LOCALE or is not a valid locale  object
41       handle.
42

RETURN VALUE

44       Upon  successful  completion, strcoll() shall return an integer greater
45       than, equal to, or less than 0, according to whether the string pointed
46       to  by s1 is greater than, equal to, or less than the string pointed to
47       by s2 when both are interpreted as appropriate to the  current  locale.
48       On  error,  strcoll() may set errno, but no return value is reserved to
49       indicate an error.
50
51       Upon successful completion, strcoll_l() shall return an integer greater
52       than, equal to, or less than 0, according to whether the string pointed
53       to by s1 is greater than, equal to, or less than the string pointed  to
54       by  s2  when  both  are interpreted as appropriate to the locale repre‐
55       sented by locale.  On error, strcoll_l() may set errno, but  no  return
56       value is reserved to indicate an error.
57

ERRORS

59       These functions may fail if:
60
61       EINVAL The  s1 or s2 arguments contain characters outside the domain of
62              the collating sequence.
63
64       The following sections are informative.
65

EXAMPLES

67   Comparing Nodes
68       The following example uses an application-defined  function,  node_com‐
69       pare(),  to  compare two nodes based on an alphabetical ordering of the
70       string field.
71
72
73           #include <string.h>
74           ...
75           struct node { /* These are stored in the table. */
76               char *string;
77               int length;
78           };
79           ...
80           int node_compare(const void *node1, const void *node2)
81           {