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 🌈

  • C11
  • POSIX.1-2008

πŸŽ€ HISTORY πŸŽ€

  • POSIX.1-2001
  • C99

she's been around. legacy icon behavior. unslay of her honestly. ⭐


🧚 NOTES 🧚

  • the behavior of wctob() depends on the LC_CTYPE category 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-safe wcrtomb(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