btowc(3)

πŸ’– btowc β€” bestie's guide to turning ONE lil byte into a wide character πŸ’–

okay so first things first, this page is btowc(3) β€” it lives in the Library Functions Manual section, section 3, we love her πŸ’…

✨ NAME ✨

btowc β€” convert single byte to wide character πŸ¦‹ (yes literally just one byte, she's not greedy)

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) β€” so like, it's already there for you, just link -lc, periodt ✨

🌸 SYNOPSIS 🌸

#include <wchar.h>

wint_t btowc(int c);

πŸ‘‘ DESCRIPTION πŸ‘‘

so the btowc() function takes c, reads it as a multibyte sequence of length 1, starting out in the initial shift state, converts it to a wide character, and hands it right back to you 🫢 adorable, right?

but bestie, listen β€” if c is EOF, or if it's not a valid multibyte sequence of length 1, btowc() hits you with WEOF. that's the sad path 😭 no wide char for you.

πŸ”₯ RETURN VALUE πŸ”₯

  • you get the wide character that got converted from the single byte c πŸŽ€
  • if c is EOF or not a valid multibyte sequence of length 1 β†’ you get WEOF πŸ’€

⭐ ATTRIBUTES ⭐

for the whole explanation of what these terms even mean, go peek at attributes(7) πŸ‘€

  • Interface: btowc()
  • Attribute: Thread safety
  • Value: MT-Safe βœ…
so yes she's MT-Safe, the girlies can call her from multiple threads, no drama πŸ’…

🌈 STANDARDS 🌈

C11, POSIX.1-2008 β€” certified iconic, no cap.

πŸŽ€ HISTORY πŸŽ€

C99, POSIX.1-2001 β€” she's been around, an OG fr fr.

πŸ’œ NOTES πŸ’œ

  • the behavior of btowc() depends on the LC_CTYPE category of the current locale 🌍 so like, what it does literally changes based on your locale, iykyk.
  • This function should never be used. 😭 not me being dramatic β€” that's the actual docs. She does NOT work for encodings which have state, and she unnecessarily treats single bytes differently from multibyte sequences. it's giving chaotic.
  • use either mbtowc(3) or the thread-safe mbrtowc(3) instead πŸ™ˆ please, for me, do that.
lowkey a warning: skip btowc(), go straight to mbtowc(3) or mbrtowc(3). this is not a drill πŸ”₯

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole vibe check bestie πŸ’– this page came from Linux man-pages 6.20, dated 2026-02-08, and honestly? slay. go forth and use mbrtowc(3) instead, ok love u, bye πŸ‘‘πŸŒΈβœ¨

πŸ“¦ 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