xref: /freebsd/lib/libc/string/strcasecmp.3 (revision 90aac0d83bc9645f51ef0c2aeae6f9c0540bb031)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)strcasecmp.3	8.1 (Berkeley) 6/9/93
31.\"
32.Dd May 29, 2014
33.Dt STRCASECMP 3
34.Os
35.Sh NAME
36.Nm strcasecmp ,
37.Nm strncasecmp
38.Nd compare strings, ignoring case
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In strings.h
43.Ft int
44.Fn strcasecmp "const char *s1" "const char *s2"
45.Ft int
46.Fn strncasecmp "const char *s1" "const char *s2" "size_t len"
47.In strings.h
48.In xlocale.h
49.Ft int
50.Fn strcasecmp_l "const char *s1" "const char *s2" "locale_t loc"
51.Ft int
52.Fn strncasecmp_l "const char *s1" "const char *s2" "size_t len" "locale_t loc"
53.Sh DESCRIPTION
54The
55.Fn strcasecmp
56and
57.Fn strncasecmp
58functions
59compare the null-terminated strings
60.Fa s1
61and
62.Fa s2 .
63.Pp
64The
65.Fn strncasecmp
66function compares at most
67.Fa len
68characters.
69The
70.Fn strcasecmp_l
71and
72.Fn strncasecmp_l
73functions do the same as their non-locale versions above, but take an
74explicit locale rather than using the current locale.
75.Sh RETURN VALUES
76The functions
77.Fn strcasecmp
78and
79.Fn strncasecmp
80return an integer greater than, equal to, or less than 0,
81depending on whether
82.Fa s1
83is lexicographically greater than, equal to, or less than
84.Fa s2
85after translation of each corresponding character to lower-case.
86The strings themselves are not modified.
87The comparison is done using unsigned characters, so that
88.Sq Li \e200
89is greater than
90.Ql \e0 .
91The functions
92.Fn strcasecmp_l
93and
94.Fn strncasecmp_l
95do the same but take explicit locales.
96.Sh SEE ALSO
97.Xr bcmp 3 ,
98.Xr memcmp 3 ,
99.Xr strcmp 3 ,
100.Xr strcoll 3 ,
101.Xr strxfrm 3 ,
102.Xr tolower 3 ,
103.Xr wcscasecmp 3
104.Sh HISTORY
105The
106.Fn strcasecmp
107and
108.Fn strncasecmp
109functions first appeared in
110.Bx 4.4 .
111Their prototypes existed previously in
112.In string.h
113before they were moved to
114.In strings.h
115for
116.St -p1003.1-2001
117compliance.
118