Debian Codegraph @

upstream/debian-unstable/man3/strcasecmp.3

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