btowc(3)

btowc3

Convert between wide and single-byte characters

Usage

#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);

Library

Standard C Library (libc, -lc)

Overview

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) for more information.

Legacy synopsis

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

Releases

145 releases since Mac OS X 10.3; the text changed 1 time.

  1. 10.3–10.4.11
  2. 10.5–26.5

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.

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.