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