---
name: "btowc"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/btowc"
---

# btowc(3)

convert between wide and single-byte characters

## NAME

**btowc**, **btowc\_l**, **wctob**, **wctob\_l** – convert between wide and single-byte characters

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<stdio.h\>**

**#include \<wchar.h\>**

*wint\_t*\

**btowc**(*int c*);

*int*\

**wctob**(*wint\_t c*);

**#include \<wchar.h\>**

**#include \<xlocale.h\>**

*wint\_t*\

**btowc\_l**(*int c*, *locale\_t loc*);

*int*\

**wctob\_l**(*wint\_t c*, *locale\_t loc*);

## DESCRIPTION

The **btowc**() function converts a single-byte character into a corresponding wide character. If the character is EOF or not valid in the initial shift state, **btowc**() returns WEOF.

The **wctob**() function converts a wide character into a corresponding single-byte character. If the wide character is WEOF or not able to be represented as a single byte in the initial shift state, **wctob**() returns WEOF.

While the **btowc**() and **wctob**() functions use the current locale, the **btowc\_l**() and **wctob\_l**() functions may be passed locales directly. See [xlocale(3)](/xlocale/3.md) for more information.

## LEGACY SYNOPSIS

The include file ⟨stdio.h⟩ is not necessary for these functions.

## SEE ALSO

[mbrtowc(3)](/mbrtowc/3.md), [multibyte(3)](/multibyte/3.md), [wcrtomb(3)](/wcrtomb/3.md), [xlocale(3)](/xlocale/3.md), [compat(5)](/compat/5.md)

## STANDARDS

The **btowc**() and **wctob**() functions conform to IEEE Std 1003.1-2001 (“POSIX.1”).

## HISTORY

The **btowc**() and **wctob**() functions first appeared in FreeBSD 5.0.
