wctob(3)
β¨ wctob β the "can I squish this wide char into ONE lil byte" test β¨
okay bestie, gather round, because we're talking about wctob, a function from the Standard C library (libc, -lc) that you are literally never supposed to use π like the manpage itself says "Never use this function" and we will get to that, don't worry.
πΈ SYNOPSIS πΈ
#include <wchar.h>
int wctob(wint_t c);
π¦ DESCRIPTION π¦
so like. wctob() checks whether the multibyte representation of the wide character c β starting from the initial state β is just a single byte. that's it, that's the whole job π
if it is? slay. it gets returned as an unsigned char. one byte. tiny. adorable. π
but here's the part where the manpage puts its hand on your shoulder and looks you dead in the eye:
Never use this function. π¨ It cannot help you in writing internationalized programs. Internationalized programs must never distinguish single-byte and multibyte characters.
so like. it's giving "built different but in a bad way." it exists, it's real, it's not your friend π
π RETURN VALUE π
wctob() gives you back the single-byte representation of c if it exists, and EOF otherwise. no in-between, no maybe, no "it depends" (okay well actually it does depend on the locale, more on that in a sec π).
π ATTRIBUTES π
for what all these fancy words even mean, go peek at attributes(7) π€
wctob()β Thread safety:MT-Safeβ she's thread safe, that's genuinely her one good quality bestie.
π STANDARDS π
C11POSIX.1-2008
π HISTORY π
POSIX.1-2001C99
she's been around. legacy icon behavior. unslay of her honestly. β
π§ NOTES π§
- the behavior of
wctob()depends on theLC_CTYPEcategory of the current locale. so like, the vibe is locale-dependent, which is exactly the kind of chaos you don't want fr fr π - and again, because it bears repeating: this function should never be used. internationalized programs must never distinguish single-byte and multibyte characters. instead use either
wctomb(3)or the thread-safewcrtomb(3)β those are the actual main characters here. periodt. π
π SEE ALSO π
and that's the teaaa π«Ά this lil page came from Linux man-pages 6.20, dated 2026-02-08, and it's all about wctob(3). love u, go use wcrtomb(3) instead, mwah ππΈβ¨
π¦ 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