xref: /freebsd/lib/libc/locale/btowc.3 (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1.\" Copyright (c) 2002 Tim J. Robbins
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd February 13, 2012
26.Dt BTOWC 3
27.Os
28.Sh NAME
29.Nm btowc ,
30.Nm wctob
31.Nd "convert between wide and single-byte characters"
32.Sh LIBRARY
33.Lb libc
34.Sh SYNOPSIS
35.In wchar.h
36.Ft wint_t
37.Fn btowc "int c"
38.Ft int
39.Fn wctob "wint_t c"
40.In wchar.h
41.In xlocale.h
42.Ft wint_t
43.Fn btowc_l "int c" "locale_t loc"
44.Ft int
45.Fn wctob_l "wint_t c" "locale_t loc"
46.Sh DESCRIPTION
47The
48.Fn btowc
49function converts a single-byte character into a corresponding wide character.
50If the character is
51.Dv EOF
52or not valid in the initial shift state,
53.Fn btowc
54returns
55.Dv WEOF .
56.Pp
57The
58.Fn wctob
59function converts a wide character into a corresponding single-byte character.
60If the wide character is
61.Dv WEOF
62or not able to be represented as a single byte in the initial shift state,
63.Fn wctob
64returns
65.Dv EOF .
66.Pp
67The _l-suffixed versions take an explicit locale argument, while the
68non-suffixed versions use the current global or per-thread locale.
69.Sh SEE ALSO
70.Xr mbrtowc 3 ,
71.Xr multibyte 3 ,
72.Xr wcrtomb 3
73.Sh STANDARDS
74The
75.Fn btowc
76and
77.Fn wctob
78functions conform to
79.St -p1003.1-2001 .
80.Sh HISTORY
81The
82.Fn btowc
83and
84.Fn wctob
85functions first appeared in
86.Fx 5.0 .
87