STRCASECMP(3POSIX)
π STRCASECMP π (that's the POSIX Programmer's Manual version, bestie)
okay so quick lil vibe check before we even start: this page lives in the POSIX Programmer's Manual, which means the Linux version of this interface might be different (so go peek at the Linux man page for the tea on Linux behavior), or honestly the interface might not even be implemented on Linux at all. π Keep that in mind, gorgeous.
β¨ NAME β¨
strcasecmp, strcasecmp_l, strncasecmp, strncasecmp_l β case-insensitive string comparisons
so basically: compare strings but pretend the caps lock key doesn't exist π
πΈ 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 π¦
okay so the plot:
strcasecmp() and strcasecmp_l() shall compare β while ignoring differences in case β the string pointed to by s1 to the string pointed to by s2.
Meanwhile strncasecmp() and strncasecmp_l() shall compare β again, ignoring case β not more than n bytes from the string pointed to by s1 to the string pointed to by s2. So like, a little sneak peek of a comparison, not the whole thing. π
Now the locale lore:
strcasecmp()andstrncasecmp()use the current locale to figure out the case of the characters.strcasecmp_l()andstrncasecmp_l()use the locale represented bylocaleto figure out 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 comes 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 about what happens outside POSIX locale, the standard literally said "idk, unspecified."
π¨ Also: 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. Not valid = not your moment. Don't do it.
π RETURN VALUE π
Upon completion, strcasecmp() and strcasecmp_l() shall return an integer that is greater than, equal to, or less than 0, depending on whether the string pointed to by s1 is β ignoring case β greater than, equal to, or less than the string pointed to by s2. Respectively, obviously. π
Upon successful completion, strncasecmp() and strncasecmp_l() shall return an integer that is greater than, equal to, or less than 0, depending on whether 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. β¨
π ERRORS π
No errors are defined.
(iconic behavior honestly, nothing to report, no drama. π«Ά)
The following sections are informative.
π EXAMPLES π
None.
π APPLICATION USAGE π
None.
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π₯ SEE ALSO π₯
wcscasecmp()- The Base Definitions volume of POSIX.1β2017,
<strings.h>
π COPYRIGHT π
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 whole page bestie, we ate and left no crumbs π β¨
this cutie came to you from the POSIX Programmer's Manual, courtesy of IEEE / The Open Group, dated 2017 β and yeah the footer is still out here being all STRCASECMP(3POSIX) like it's subtle. mwah. π«ΆπΈ
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms