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
cisEOFor not a valid multibyte sequence of length 1 β you getWEOFπ
β 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 theLC_CTYPEcategory 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-safembrtowc(3)instead π please, for me, do that.
lowkey a warning: skipbtowc(), go straight tombtowc(3)ormbrtowc(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