Debian Codegraph @

upstream/debian-trixie/man3/strcasecmp.3

raw
1 '\" t
2 .\" Copyright 1993 David Metcalfe ([email protected])
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" 386BSD man pages
10 .\" Modified Sat Jul 24 18:12:45 1993 by Rik Faith ([email protected])
11 .TH strcasecmp 3 2024-05-02 "Linux man-pages 6.9.1"
12 .SH NAME
13 strcasecmp, strncasecmp \- compare two strings ignoring case
14 .SH LIBRARY
15 Standard C library
16 .RI ( libc ", " \-lc )
17 .SH SYNOPSIS
18 .nf
19 .B #include <strings.h>
20 .P
21 .BI "int strcasecmp(const char *" s1 ", const char *" s2 );
22 .BI "int strncasecmp(const char " s1 [. n "], const char " s2 [. n "], \
23 size_t " n );
24 .fi
25 .SH DESCRIPTION
26 The
27 .BR strcasecmp ()
28 function performs a byte-by-byte comparison of the strings
29 .I s1
30 and
31 .IR s2 ,
32 ignoring the case of the characters.
33 It returns an integer
34 less than, equal to, or greater than zero if
35 .I s1
36 is found,
37 respectively, to be less than, to match, or be greater than
38 .IR s2 .
39 .P
40 The
41 .BR strncasecmp ()
42 function is similar, except that it compares
43 no more than
44 .I n
45 bytes of
46 .I s1
47 and
48 .IR s2 .
49 .SH RETURN VALUE
50 The
51 .BR strcasecmp ()
52 and
53 .BR strncasecmp ()
54 functions return
55 an integer less than, equal to, or greater than zero if
56 .I s1
57 is, after ignoring case, found to be
58 less than, to match, or be greater than
59 .IR s2 ,
60 respectively.
61 .SH ATTRIBUTES
62 For an explanation of the terms used in this section, see
63 .BR attributes (7).
64 .TS
65 allbox;
66 lbx lb lb
67 l l l.
68 Interface Attribute Value
69 T{
70 .na
71 .nh
72 .BR strcasecmp (),
73 .BR strncasecmp ()
74 T} Thread safety MT-Safe locale
75 .TE
76 .SH STANDARDS
77 POSIX.1-2008.
78 .SH HISTORY
79 4.4BSD, POSIX.1-2001.
80 .P
81 The
82 .BR strcasecmp ()
83 and
84 .BR strncasecmp ()
85 functions first appeared in 4.4BSD, where they were declared in
86 .IR <string.h> .
87 Thus, for reasons of historical compatibility, the glibc
88 .I <string.h>
89 header file also declares these functions, if the
90 .B _DEFAULT_SOURCE
91 (or, in glibc 2.19 and earlier,
92 .BR _BSD_SOURCE )
93 feature test macro is defined.
94 .P
95 The POSIX.1-2008 standard says of these functions:
96 .P
97 .RS
98 When the
99 .B LC_CTYPE
100 category of the locale being used is from the POSIX locale,
101 these functions shall behave as if the strings had been converted
102 to lowercase and then a byte comparison performed.
103 Otherwise, the results are unspecified.
104 .RE
105 .SH SEE ALSO
106 .BR memcmp (3),
107 .BR strcmp (3),
108 .BR strcoll (3),
109 .BR string (3),
110 .BR strncmp (3),
111 .BR wcscasecmp (3),
112 .BR wcsncasecmp (3)