1STRCOLL(3P) POSIX Programmer's Manual STRCOLL(3P)
2
3
4
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
12 strcoll - string comparison using collating information
13
15 #include <string.h>
16
17 int strcoll(const char *s1, const char *s2);
18
19
21 The strcoll() function shall compare the string pointed to by s1 to the
22 string pointed to by s2, both interpreted as appropriate to the LC_COL‐
23 LATE category of the current locale.
24
25 The strcoll() function shall not change the setting of errno if suc‐
26 cessful.
27
28 Since no return value is reserved to indicate an error, an application
29 wishing to check for error situations should set errno to 0, then call
30 strcoll(), then check errno.
31
33 Upon successful completion, strcoll() shall return an integer greater
34 than, equal to, or less than 0, according to whether the string pointed
35 to by s1 is greater than, equal to, or less than the string pointed to
36 by s2 when both are interpreted as appropriate to the current locale.
37 On error, strcoll() may set errno, but no return value is reserved to
38 indicate an error.
39
41 The strcoll() function may fail if:
42
43 EINVAL The s1 or s2 arguments contain characters outside the domain of
44 the collating sequence.
45
46
47 The following sections are informative.
48
50 Comparing Nodes
51 The following example uses an application-defined function, node_com‐
52 pare(), to compare two nodes based on an alphabetical ordering of the
53 string field.
54
55
56 #include <string.h>
57 ...
58 struct node { /* These are stored in the table. */
59 char *string;
60 int length;
61 };
62 ...
63 int node_compare(const void *node1, const void *node2)
64 {
65 return strcoll(((const struct node *)node1)->string,
66 ((const struct node *)node2)->string);
67 }
68 ...
69
71 The strxfrm() and strcmp() functions should be used for sorting large
72 lists.
73
75 None.
76
78 None.
79
81 strcmp(), strxfrm(), the Base Definitions volume of
82 IEEE Std 1003.1-2001, <string.h>
83
85 Portions of this text are reprinted and reproduced in electronic form
86 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
87 -- Portable Operating System Interface (POSIX), The Open Group Base
88 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
89 Electrical and Electronics Engineers, Inc and The Open Group. In the
90 event of any discrepancy between this version and the original IEEE and
91 The Open Group Standard, the original IEEE and The Open Group Standard
92 is the referee document. The original Standard can be obtained online
93 at http://www.opengroup.org/unix/online.html .
94
95
96
97IEEE/The Open Group 2003 STRCOLL(3P)