wcscasecmp(3)
π wcscasecmp(3) β the wide-char girlies who don't care about case π
okay bestie, sit down, hydrate, because we're talking about wcscasecmp and wcsncasecmp β two absolute icons from the Library Functions Manual of the wcscasecmp(3) page. they compare two wide-character strings and just. don't. care. about case. lowercase, uppercase, whatever, they're not judging π
β¨ NAME β¨
wcscasecmp, wcsncasecmp β compare two wide-character strings, ignoring case
like, fr fr, that's the whole vibe. two wide strings walk in, case gets ignored, somebody's declared greater. iconic behavior.
π LIBRARY π
Standard C library (libc, -lc)
so you gotta link the -lc bestie, that's where the magic lives πΈ
π¦ SYNOPSIS π¦
#include <wchar.h>
int wcscasecmp(const wchar_t *s1, const wchar_t *s2);
int wcsncasecmp(const wchar_t s1[], const wchar_t s2[], size_t n);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
wcscasecmp(), wcsncasecmp():
- Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
- Before glibc 2.10:
_GNU_SOURCE
so depending on how ancient your glibc is, you either flex _POSIX_C_SOURCE >= 200809L or you go full old-school and define _GNU_SOURCE. glow-up requirements, basically β¨
π DESCRIPTION π
so wcscasecmp() is literally the wide-character equivalent of the strcasecmp(3) function. she takes the wide-character string pointed to by s1 and the wide-character string pointed to by s2 and compares them, ignoring case differences β shoutout to towupper(3) and towlower(3) for handling that part, they're the ones doing the case-flipping behind the scenes π«Ά
and wcsncasecmp()? she's the same energy, the wide-character equivalent of strncasecmp(3), except she compares no more than n wide characters of s1 and s2. boundaries, bestie. she has them. n is the limit and she respects it π
π RETURN VALUE π
wcscasecmp() and wcsncasecmp() hand you back an integer that is:
- less than zero β
s1is, after ignoring case, found to be less thans2 - equal to zero β
s1matchess2 - greater than zero β
s1is, after ignoring case, found to be greater thans2
that's it. that's the whole report card. no cap π
π₯ ATTRIBUTES π₯
for the full explanation of what these terms even mean, go peek at attributes(7) β she explains everything, she's the source.
wcscasecmp(),wcsncasecmp()β Thread safety: MT-Safe locale
so yes, thread-safe, but she's locale-dependent about it β MT-Safe locale is the exact vibe, don't forget the locale part π
β STANDARDS β
POSIX.1-2008.
certified, standardized, official. she said "I'm in the spec" and she was right π
π§ HISTORY π§
glibc 2.1.
she's been here since glibc 2.1, an elder stateswoman of wide-char case-insensitive comparison, and she's still serving πΈ
π NOTES π
the behavior of wcscasecmp() depends on the LC_CTYPE category of the current locale.
β οΈ bestie this matters β swap your locale, swap her whole attitude. LC_CTYPE is running the show here, so set it with intention, mwah π
π SEE ALSO π
go read those too, they're her cousins and they also ate β¨
okay that's the whole page, you're officially educated π
and one last thing β this lil masterpiece lives in Linux man-pages 6.20, dated 2026-02-08, page wcscasecmp(3). so when you cite her, cite her correctly bestie π bye, ily, go compare some wide strings β¨π¦π
π¦ where this page comes from
- 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 6.20
- π the page's license: GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms