STRCASECMP(3P)
π STRCASECMP(3P) β the POSIX Programmer's Manual, but make it a group chat π
okay bestie, welcome to the POSIX Programmer's Manual. this page? it's strcasecmp and its little friend group. we're comparing strings but we do NOT care about case. uppercase, lowercase, whatever, we're not judging π
πΈ PROLOG πΈ
real talk before we start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so go consult the corresponding Linux manual page if you wanna know what Linux actually does. or, plot twist, the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
strcasecmp, strcasecmp_l, strncasecmp, strncasecmp_l β case-insensitive string comparisons
yes queen, comparisons that don't care about case. the whole squad.
π SYNOPSIS π
#include <strings.h>
int strcasecmp(const char *s1, const char *s2);
int strcasecmp_l(const char *s1, const char *s2,
locale_t locale);
int strncasecmp(const char *s1, const char *s2, size_t n);
int strncasecmp_l(const char *s1, const char *s2,
size_t n, locale_t locale);
π¦ DESCRIPTION π¦
so, strcasecmp() and strcasecmp_l() shall compare the string pointed to by s1 to the string pointed to by s2, while ignoring differences in case. that's the whole vibe. the case is not the moment.
and strncasecmp() and strncasecmp_l()? same energy, but they compare not more than n bytes from the string pointed to by s1 to the string pointed to by s2, still ignoring case differences. we're keeping it cute and contained.
now the locale tea β:
strcasecmp()andstrncasecmp()use the current locale to determine the case of the characters.strcasecmp_l()andstrncasecmp_l()use the locale represented bylocaleto determine the case of the characters.
and here's the part where you gotta pay attention, bestie. when the LC_CTYPE category of the locale being used is from the POSIX locale, these functions shall behave as if the strings had been converted to lowercase and then a byte comparison performed. otherwise? the results are unspecified. π so don't come crying to me if your locale is doing its own thing.
π¨ BIG warning energy: the behavior is undefined if thelocaleargument tostrcasecmp_l()orstrncasecmp_l()is the special locale objectLC_GLOBAL_LOCALE, or if it's not a valid locale object handle. that's not a vibe. that's undefined behavior. don't do it. periodt.
π RETURN VALUE π
upon completion, strcasecmp() and strcasecmp_l() shall return an integer that is greater than, equal to, or less than 0, if the string pointed to by s1 is, ignoring case, greater than, equal to, or less than the string pointed to by s2, respectively. iconic. simple. no notes.
upon successful completion, strncasecmp() and strncasecmp_l() shall return an integer that is greater than, equal to, or less than 0, if the possibly null-terminated array pointed to by s1 is, ignoring case, greater than, equal to, or less than the possibly null-terminated array pointed to by s2, respectively. same energy, n-bytes flavored. π
π ERRORS π
no errors are defined. nothing to report, we ate and left no crumbs.
the following sections are informative. iykyk.
π EXAMPLES π
None.
(not me showing up with zero examples. the audacity. π)
π APPLICATION USAGE π
None.
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
wcscasecmp()- the Base Definitions volume of POSIX.1β2017,
<strings.h>
π₯ COPYRIGHT π₯
okay legal bestie, here we go, word for word, don't skip it:
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the page, bestie π«Ά β signed off by IEEE/The Open Group, 2017, which is the source, the version AND the date all at once, so you know exactly who's responsible for this masterpiece. mwah πβ¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms