wcsnlen(3)
πΈ wcsnlen(3) β aka "how long is this wide string, but make it β¨boundedβ¨"
okay bestie, welcome to the wcsnlen page, from the Library Functions Manual π
LIBRARY: Standard C library (libc, -lc) π«Ά
β¨ SYNOPSIS β¨
#include <wchar.h>
size_t wcsnlen(const wchar_t s[], size_t maxlen);
π Feature Test Macro Requirements for glibc
(psst, go look at feature_test_macros(7) if you don't know what these are, iykyk)
wcsnlen():
- Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
- Before glibc 2.10:
_GNU_SOURCE
π DESCRIPTION
So likeβ¦ wcsnlen() is literally the wide-character version of strnlen(3). That's the whole vibe. π
It gives you back the number of wide-characters in the string that s points at β and not counting the terminating null wide character (L'\0') β but it caps out at maxlen wide characters.
β οΈ not me stressing this enough: maxlen is not a byte count. it's wide characters, bestie. do not get it twisted. π
And while it's doing all that, wcsnlen() only ever peeks at the first maxlen wide characters at s, and it never looks past s[maxlen-1]. no overstepping, no scrolling past the boundary, respectful queen behavior fr fr. π¦
π RETURN VALUE
wcsnlen() hands you back wcslen(s) β but only if that's less than maxlen. Otherwise (aka if there's no null wide character hanging out among those first maxlen wide characters that s points to) it just returns maxlen. Simple. Iconic. No drama. β
π ATTRIBUTES
For the whole explanation of what these terms even mean, go check attributes(7). π§
- Interface:
wcsnlen() - Attribute: Thread safety
- Value:
MT-Safe
yes bestie, MT-Safe β she's safe to call from multiple threads, periodt. π
π STANDARDS
POSIX.1-2008. β¨ certified, official, on the list.
π¦ HISTORY
glibc 2.1. she's been here since forever, a true elder of the game.
π« SEE ALSO
okay that's the whole page!! go forth and count your wide characters responsibly, bestie π πΈ
Linux man-pages 6.20 β dated 2026-02-08 π mwah, love u, bye!! π
π¦ 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