wcsnrtombs(3)
β¨ NAME β¨
wcsnrtombs β convert a wide-character string to a multibyte string. And yes bestie, this is wcsnrtombs(3) from the Library Functions Manual π
π LIBRARY π
Standard C library (libc, -lc) π«Ά
πΈ SYNOPSIS πΈ
#include <wchar.h>
size_t wcsnrtombs(size_t dsize;
char dest[restrict dsize],
const wchar_t **restrict src,
size_t nwc, size_t dsize, mbstate_t *restrict ps);
π§ Feature Test Macro Requirements for glibc (see feature_test_macros(7)) π§
wcsnrtombs():
Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_GNU_SOURCE
π DESCRIPTION π
Okay so wcsnrtombs() is literally like wcsrtombs(3), except the number of wide characters it converts, starting at *src, is capped at nwc. Periodt.
If dest is not NULL, wcsnrtombs() converts at most nwc wide characters from the wide-character string *src into a multibyte string starting at dest. At most dsize bytes get written to dest. The shift state *ps is updated. The conversion is effectively done by repeatedly calling wcrtomb(dest, *src, ps), as long as that call succeeds, and then incrementing dest by the number of bytes written and *src by one. The conversion can stop for three reasons:
- A wide character shows up that can not be represented as a multibyte sequence according to the current locale. In this case,
*srcis left pointing to that invalid wide character,(size_t) -1is returned, anderrnois set toEILSEQ. π nwcwide characters have been converted without hitting a null wide character (L'\0'), or the size limit forces a stop. In this case,*srcis left pointing to the next wide character to be converted, and the number of bytes written todestis returned.- The wide-character string has been completely converted, including the terminating null wide character (which has the side effect of bringing
*psback to the initial state). In this case,*srcis set toNULL, and the number of bytes written todest, excluding the terminating null byte ('\0'), is returned. Slay.
If dest is NULL, dsize is ignored, and the conversion proceeds like above, except the converted bytes are not written out to memory, and no destination size limit exists.
In both of the above cases, if ps is NULL, a static anonymous state known only to the wcsnrtombs() function is used instead.
The programmer must ensure that there is room for at least dsize bytes at dest. That's on you, bestie, fr fr.
π₯ RETURN VALUE π₯
wcsnrtombs() returns the number of bytes that make up the converted part of multibyte sequence, not including the terminating null byte. If a wide character was encountered which could not be converted, (size_t) -1 is returned, and errno is set to EILSEQ.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
wcsnrtombs() - Attribute: Thread safety
- Value:
MT-Unsafe race:wcsnrtombs/!ps
π STANDARDS π
POSIX.1-2008.
π NOTES π
The behavior of wcsnrtombs() depends on the LC_CTYPE category of the current locale.
Passing NULL as ps is not multithread safe.
This is the part where you screenshot and send to the group chat:NULLaspsis not multithread safe. π¨
π¦ SEE ALSO π¦
mwah π this page came from Linux man-pages 6.20, dated 2026-02-08. go forth and convert, bestie π«Άβ¨
π¦ 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