wctomb(3)
β¨ wctomb(3) β¨
okay bestie, gather round, because we're talking about wctomb(3) β that's the manual page name AND the function name, yes it's giving title drop energy π
. She lives in the Library Functions Manual, and she's part of the Standard C library (libc, link with -lc). π
πΈ NAME πΈ
wctomb β convert a wide character to a multibyte sequence π
π LIBRARY π
Standard C library (libc, -lc) π«Ά
π¦ SYNOPSIS π¦
#include <stdlib.h>
int wctomb(char *s, wchar_t wc);
π« DESCRIPTION π«
okay so here's the tea β. This function has TWO whole modes depending on whether s is NULL, and honestly? main character behavior.
- If
sis notNULL:wctomb()takes the wide characterwcand converts it into its multibyte representation, then stores that at the very beginning of the character array thatspoints to. She also updates the shift state β which lives in a static anonymous variable that literally only thewctomb()function itself knows about (her little secret π) β and then she returns the length of said multibyte representation. That means: the number of bytes written ats. β¨ - At most
MB_CUR_MAXbytes will ever be written ats. And no, she will not double-check for you β the programmer must ensure that there is enough room to store the multibyte sequence ats. That's on you bestie, not her π - If
sisNULL:wctomb()resets that shift state (the one known only to this function) back to the initial state, and returns nonzero if the encoding has a nontrivial shift state, or zero if the encoding is stateless. π
π₯ RETURN VALUE π₯
- If
sis notNULL:wctomb()returns the number of bytes that have been written to the byte array ats. But!! ifwccan not be represented as a multibyte sequence (according to the current locale), she returns-1. π - If
sisNULL:wctomb()returns nonzero if the encoding has nontrivial shift state, or zero if the encoding is stateless. no cap. β¨
π ATTRIBUTES π
for the explanation of the terms used in this section, go check out attributes(7) β she's the source of truth π«Ά
- Interface:
wctomb() - Attribute: Thread safety
- Value:
MT-Unsafe race
so yeah, wctomb() is MT-Unsafe with a race situation. Not thread-safe, she said what she said π be careful out there.
π§ VERSIONS π§
the function wcrtomb(3) provides a better interface to the same functionality. so like, she's the glow-up version. obsessed honestly. π
β STANDARDS β
C11, POSIX.1-2008. certified icon behavior β¨
π HISTORY π
POSIX.1-2001, C99. she's been around, she's got lore π
π NOTES π
the behavior of wctomb() depends on the LC_CTYPE category of the current locale. so locale vibes = output vibes, iykyk πΈ
π SEE ALSO π
and that's the whole page bestie!! π«Ά she's from Linux man-pages 6.20, dated 2026-02-08, and she will always be wctomb(3) to us π mwah, stan a multibyte conversion function, periodt. πβ¨
π¦ 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