xref: /freebsd/lib/libc/locale/wctomb.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
18b810927STim J. Robbins.\" Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
2bc0b3a18STim J. Robbins.\" Copyright (c) 1993
3bc0b3a18STim J. Robbins.\"	The Regents of the University of California.  All rights reserved.
4bc0b3a18STim J. Robbins.\"
5bc0b3a18STim J. Robbins.\" This code is derived from software contributed to Berkeley by
6bc0b3a18STim J. Robbins.\" Donn Seeley of BSDI.
7bc0b3a18STim J. Robbins.\"
8bc0b3a18STim J. Robbins.\" Redistribution and use in source and binary forms, with or without
9bc0b3a18STim J. Robbins.\" modification, are permitted provided that the following conditions
10bc0b3a18STim J. Robbins.\" are met:
11bc0b3a18STim J. Robbins.\" 1. Redistributions of source code must retain the above copyright
12bc0b3a18STim J. Robbins.\"    notice, this list of conditions and the following disclaimer.
13bc0b3a18STim J. Robbins.\" 2. Redistributions in binary form must reproduce the above copyright
14bc0b3a18STim J. Robbins.\"    notice, this list of conditions and the following disclaimer in the
15bc0b3a18STim J. Robbins.\"    documentation and/or other materials provided with the distribution.
16*fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
17bc0b3a18STim J. Robbins.\"    may be used to endorse or promote products derived from this software
18bc0b3a18STim J. Robbins.\"    without specific prior written permission.
19bc0b3a18STim J. Robbins.\"
20bc0b3a18STim J. Robbins.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21bc0b3a18STim J. Robbins.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22bc0b3a18STim J. Robbins.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23bc0b3a18STim J. Robbins.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24bc0b3a18STim J. Robbins.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25bc0b3a18STim J. Robbins.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26bc0b3a18STim J. Robbins.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27bc0b3a18STim J. Robbins.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28bc0b3a18STim J. Robbins.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29bc0b3a18STim J. Robbins.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30bc0b3a18STim J. Robbins.\" SUCH DAMAGE.
31bc0b3a18STim J. Robbins.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
32bc0b3a18STim J. Robbins.\"
338b810927STim J. Robbins.Dd April 8, 2004
34bc0b3a18STim J. Robbins.Dt WCTOMB 3
35bc0b3a18STim J. Robbins.Os
36bc0b3a18STim J. Robbins.Sh NAME
37bc0b3a18STim J. Robbins.Nm wctomb
38bc0b3a18STim J. Robbins.Nd convert a wide-character code to a character
39bc0b3a18STim J. Robbins.Sh LIBRARY
40bc0b3a18STim J. Robbins.Lb libc
41bc0b3a18STim J. Robbins.Sh SYNOPSIS
42bc0b3a18STim J. Robbins.In stdlib.h
43bc0b3a18STim J. Robbins.Ft int
44bc0b3a18STim J. Robbins.Fn wctomb "char *mbchar" "wchar_t wchar"
45bc0b3a18STim J. Robbins.Sh DESCRIPTION
46bc0b3a18STim J. RobbinsThe
47bc0b3a18STim J. Robbins.Fn wctomb
48bc0b3a18STim J. Robbinsfunction converts a wide character
49bc0b3a18STim J. Robbins.Fa wchar
50bc0b3a18STim J. Robbinsinto a multibyte character and stores
51bc0b3a18STim J. Robbinsthe result in
52bc0b3a18STim J. Robbins.Fa mbchar .
53bc0b3a18STim J. RobbinsThe object pointed to by
54bc0b3a18STim J. Robbins.Fa mbchar
55bc0b3a18STim J. Robbinsmust be large enough to accommodate the multibyte character, which
56bc0b3a18STim J. Robbinsmay be up to
57bc0b3a18STim J. Robbins.Dv MB_LEN_MAX
58bc0b3a18STim J. Robbinsbytes.
59bc0b3a18STim J. Robbins.Pp
60bc0b3a18STim J. RobbinsA call with a null
61bc0b3a18STim J. Robbins.Fa mbchar
62bc0b3a18STim J. Robbinspointer returns nonzero if the current locale requires shift states,
63bc0b3a18STim J. Robbinszero otherwise;
64bc0b3a18STim J. Robbinsif shift states are required, the shift state is reset to the initial state.
65bc0b3a18STim J. Robbins.Sh RETURN VALUES
66bc0b3a18STim J. RobbinsIf
67bc0b3a18STim J. Robbins.Fa mbchar
68bc0b3a18STim J. Robbinsis
69bc0b3a18STim J. Robbins.Dv NULL ,
70bc0b3a18STim J. Robbinsthe
71bc0b3a18STim J. Robbins.Fn wctomb
72bc0b3a18STim J. Robbinsfunction returns nonzero if shift states are supported,
73bc0b3a18STim J. Robbinszero otherwise.
74bc0b3a18STim J. RobbinsIf
75bc0b3a18STim J. Robbins.Fa mbchar
76bc0b3a18STim J. Robbinsis valid,
77bc0b3a18STim J. Robbins.Fn wctomb
78bc0b3a18STim J. Robbinsreturns
79bc0b3a18STim J. Robbinsthe number of bytes processed in
80bc0b3a18STim J. Robbins.Fa mbchar ,
81bc0b3a18STim J. Robbinsor \-1 if no multibyte character
82bc0b3a18STim J. Robbinscould be recognized or converted.
838b810927STim J. RobbinsIn this case,
84b9384efcSRuslan Ermilov.Fn wctomb Ns 's
858b810927STim J. Robbinsinternal conversion state is undefined.
86bc0b3a18STim J. Robbins.Sh ERRORS
87bc0b3a18STim J. RobbinsThe
88bc0b3a18STim J. Robbins.Fn wctomb
89bc0b3a18STim J. Robbinsfunction will fail if:
90bc0b3a18STim J. Robbins.Bl -tag -width Er
91bc0b3a18STim J. Robbins.It Bq Er EILSEQ
92bc0b3a18STim J. RobbinsAn invalid multibyte sequence was detected.
938b810927STim J. Robbins.It Bq Er EINVAL
948b810927STim J. RobbinsThe internal conversion state is invalid.
95bc0b3a18STim J. Robbins.El
96bc0b3a18STim J. Robbins.Sh SEE ALSO
97bc0b3a18STim J. Robbins.Xr mbtowc 3 ,
98bc0b3a18STim J. Robbins.Xr wcrtomb 3 ,
99bc0b3a18STim J. Robbins.Xr wcstombs 3 ,
100bc0b3a18STim J. Robbins.Xr wctob 3
101bc0b3a18STim J. Robbins.Sh STANDARDS
102bc0b3a18STim J. RobbinsThe
103bc0b3a18STim J. Robbins.Fn wctomb
104bc0b3a18STim J. Robbinsfunction conforms to
1058b810927STim J. Robbins.St -isoC-99 .
106