WCSNCPY(3POSIX)
WCSNCPY(3POSIX) π
okay bestie, gather round, because we're reading a page straight out of the POSIX Programmer's Manual and honestly? it's giving β¨specification energyβ¨ in the best way. two functions, one tiny job, and a whole lot of "please don't overlap ur buffers, i'm begging". let's get into it π«Ά
πΈ PROLOG πΈ
so, real talk: this manual page is part of the POSIX Programmer's Manual. that's the vibe.
but β οΈ heads up β the Linux implementation of this interface may differ. like, if you're on Linux, go consult the corresponding Linux manual page for the actual Linux behavior, ok? orβ¦ plot twistβ¦ the interface might not even be implemented on Linux at all π. check before you ship, bestie.
β¨ NAME β¨
wcpncpy,wcsncpyβ copy a fixed-size wide-character string, returning a pointer to its end π
π SYNOPSIS π
#include <wchar.h>
wchar_t *wcpncpy(wchar_t restrict *ws1, const wchar_t *restrict ws2,
size_t n);
wchar_t *wcsncpy(wchar_t *restrict ws1, const wchar_t *restrict ws2,
size_t n);
π¦ DESCRIPTION π¦
For wcsncpy(): the functionality described on this reference page is aligned with the ISO C standard. and if there's any conflict between what's written here and the ISO C standard? that conflict is unintentional, fr fr. this volume of POSIX.1β2017 defers to the ISO C standard, periodt. π
now the actual tea β β the wcpncpy() and wcsncpy() functions shall copy not more than n wide-character codes (and btw, wide-character codes that follow a null wide-character code are not copied) from the array pointed to by ws2 to the array pointed to by ws1.
π¨ okay this is the important one: if copying takes place between objects that overlap, the behavior is undefined. like, undefined-undefined. don't do it. i'm not joking. π
and if the array pointed to by ws2 is a wide-character string that's shorter than n wide-character codes? then null wide-character codes shall be appended to the copy in the array pointed to by ws1, until n wide-character codes in all are written. padding arc π
π RETURN VALUE π
if any null wide-character codes were written into the destination, the wcpncpy() function shall return the address of the first such null wide-character code. otherwise? it shall return &ws1[n]. iconic.
the wcsncpy() function shall return ws1. simple. clean. main character energy.
and no return values are reserved to indicate an error. so likeβ¦ it won't tell you if something went wrong. it's not a snitch π
π ERRORS π
no errors are defined. that's it, that's the section π«Ά
The following sections are informative.
π EXAMPLES π
None.
(yes bestie, literally none. the void. nothing. π³οΈ)
π APPLICATION USAGE π
if there is no null wide-character code in the first n wide-character codes of the array pointed to by ws2, the result is not null-terminated. β οΈ so if you're expecting a nice little terminator at the endβ¦ it might just not be there. check ur lengths, bestie.
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π₯ SEE ALSO π₯
strncpy()wcscpy()
and the Base Definitions volume of POSIX.1β2017, <wchar.h> π
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document β it's the final boss, no cap. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . π
and that's the whole thing!! brought to you by IEEE/The Open Group, 2017, under the name WCSNCPY(3POSIX) β mwah, go copy some wide characters responsibly, bestie π
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms