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