wcsspn(3)
β¨ wcsspn(3) β¨
okay bestie, gather round, because today we're talking about wcsspn from the Library Functions Manual β she lives in the Standard C library (libc, link with -lc) and she is so much chiller than her name makes her look π
π NAME π
wcsspn β get the length of a prefix wide-character substring. that's it. that's the job. very demure, very mindful π
π LIBRARY π
Standard C library (libc, -lc) π«Ά
πΈ SYNOPSIS πΈ
#include <wchar.h>
size_t wcsspn(const wchar_t *wcs, const wchar_t *accept);
π DESCRIPTION π
okay so. wcsspn() is literally the wide-character version of strspn(3) β¨ β like, same energy, but for wide chars.
Here's the vibe: it goes through wcs from the very start and asks "how far can I walk while every single character I step on is on the guest list?" The guest list is accept. The second it hits a wide character that is not listed in accept, it stops and tells you how many steps it took. πΆβοΈ
So basically it determines the length of the longest initial segment of wcs that's made up entirely of wide characters listed in accept. In other words: it searches for the first occurrence, inside the wide-character string wcs, of a wide character that is not contained in the wide-character string accept. no cap π₯
π¦ RETURN VALUE π¦
wcsspn() returns the number of wide characters in that longest initial segment of wcs which consists entirely of wide characters listed in accept. π―
Or, said the other way (same tea, different mug): it returns the position of the first occurrence in the wide-character string wcs of a wide character that is not contained in the wide-character string accept β or, if there is no such character at all, it returns wcslen(wcs). π
π ATTRIBUTES π
for the explanation of the terms used in this section, go check out attributes(7) bestie π«Ά
- Interface:
wcsspn()- Attribute: Thread safety
- Value:
MT-Safeβ¨
π STANDARDS π
- C11
- POSIX.1-2008
π HISTORY π
- POSIX.1-2001
- C99
π SEE ALSO π
aaand that's the whole page, bestie π that was Linux man-pages 6.20, dated 2026-02-08 β and yes, the page is literally called wcsspn(3), the way that it ate and left no crumbs πβ¨π
π¦ 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