wcpncpy(3)

πŸ’– wcpncpy(3) πŸ’–

okay bestie, so this is wcpncpy(3) from the Library Functions Manual β€” yes, the Library Functions Manual, the one we all know and love πŸŽ€. sit down, grab a boba, and let me tell you about the wide-character girlboss who copies strings and then points you to the end of her work. no cap.


✨ NAME ✨

wcpncpy β€” copy a fixed-size string of wide characters, returning a pointer to its end

like, she copies a fixed-size string of wide characters AND hands you back a pointer to the end. multitasking queen πŸ‘‘


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

the classic. the original. the one that raised us 🫢


🌈 SYNOPSIS 🌈

#include <wchar.h>

wchar_t *wcpncpy(size_t n;
                 wchar_t dest[restrict n],
                 const wchar_t *restrict src,
                 size_t n);

🧚 Feature Test Macro Requirements for glibc 🧚

(peep feature_test_macros(7) if u wanna know more, bestie)

wcpncpy():
    Since glibc 2.10:
        _POSIX_C_SOURCE >= 200809L
    Before glibc 2.10:
        _GNU_SOURCE

so if ur on glibc 2.10 or later u need _POSIX_C_SOURCE >= 200809L, and if ur on something older than glibc 2.10 u need _GNU_SOURCE. the way glibc keeps receipts of its own history... iconic honestly πŸ’…


πŸ’… DESCRIPTION πŸ’…

so wcpncpy() is literally the wide-character equivalent of the stpncpy(3) function. that's the whole vibe. she's the wide-char sister πŸ¦‹

she copies at most n wide characters from the wide-character string pointed to by src β€” including the terminating null wide (L'\0') β€” over to the array pointed to by dest. and exactly n wide characters get written at dest. exactly. she does not do half measures, bestie ✨

here's the tea tho:

  • if the length wcslen(src) is smaller than n, the remaining wide characters in the array pointed to by dest are filled with L'\0' characters. padding queen πŸŽ€
  • if the length wcslen(src) is greater than or equal to n, the string pointed to by dest will not be L'\0' terminated. 😭 no null terminator. she just... stops. it's giving cliffhanger.
⚠️ okay this is important β€” the strings may not overlap. do not make them overlap. that's cursed behaviour territory, and not the fun kind of cursed πŸ’€
⚠️ and also β€” the programmer must ensure that there is room for at least n wide characters at dest. that's on YOU, bestie. she is not checking. she is trusting u. do not betray her trust πŸ™ˆ

πŸ”₯ RETURN VALUE πŸ”₯

wcpncpy() returns a pointer to one past the last non-null wide character written β€” that is:

dest + wcsnlen(src, n)

so she walks u to the finish line. main character exit πŸšΆβ™€οΈβœ¨


πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, peep attributes(7). it's required reading, iykyk.

  • Interface: wcpncpy()
  • Attribute: Thread safety
  • Value: MT-Safe

translation: MT-Safe means she's thread-safe, so multiple threads can hang out with her at the same time and nobody's gonna start drama πŸ”₯


⭐ STANDARDS ⭐

POSIX.1-2008.

certified. official. no notes. periodt πŸ’…


🌸 SEE ALSO 🌸

go read those too, bestie, the family is adorable 🫢


and that's the whole page!! πŸ¦‹πŸ’– this little baby lives in Linux man-pages 6.20, dated 2026-02-08. love that for her. go forth and copy wide characters responsibly, and remember: exactly n or nothing at all βœ¨πŸŽ€πŸ’œ

πŸ“¦ 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