xref: /freebsd/lib/libc/locale/wctomb.3 (revision fbbd9655e5107c68e4e0146ff22b73d7350475bc)
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.\"
32bc0b3a18STim J. Robbins.\" From @(#)multibyte.3	8.1 (Berkeley) 6/4/93
33bc0b3a18STim J. Robbins.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
34bc0b3a18STim J. Robbins.\" $FreeBSD$
35bc0b3a18STim J. Robbins.\"
368b810927STim J. Robbins.Dd April 8, 2004
37bc0b3a18STim J. Robbins.Dt WCTOMB 3
38bc0b3a18STim J. Robbins.Os
39bc0b3a18STim J. Robbins.Sh NAME
40bc0b3a18STim J. Robbins.Nm wctomb
41bc0b3a18STim J. Robbins.Nd convert a wide-character code to a character
42bc0b3a18STim J. Robbins.Sh LIBRARY
43bc0b3a18STim J. Robbins.Lb libc
44bc0b3a18STim J. Robbins.Sh SYNOPSIS
45bc0b3a18STim J. Robbins.In stdlib.h
46bc0b3a18STim J. Robbins.Ft int
47bc0b3a18STim J. Robbins.Fn wctomb "char *mbchar" "wchar_t wchar"
48bc0b3a18STim J. Robbins.Sh DESCRIPTION
49bc0b3a18STim J. RobbinsThe
50bc0b3a18STim J. Robbins.Fn wctomb
51bc0b3a18STim J. Robbinsfunction converts a wide character
52bc0b3a18STim J. Robbins.Fa wchar
53bc0b3a18STim J. Robbinsinto a multibyte character and stores
54bc0b3a18STim J. Robbinsthe result in
55bc0b3a18STim J. Robbins.Fa mbchar .
56bc0b3a18STim J. RobbinsThe object pointed to by
57bc0b3a18STim J. Robbins.Fa mbchar
58bc0b3a18STim J. Robbinsmust be large enough to accommodate the multibyte character, which
59bc0b3a18STim J. Robbinsmay be up to
60bc0b3a18STim J. Robbins.Dv MB_LEN_MAX
61bc0b3a18STim J. Robbinsbytes.
62bc0b3a18STim J. Robbins.Pp
63bc0b3a18STim J. RobbinsA call with a null
64bc0b3a18STim J. Robbins.Fa mbchar
65bc0b3a18STim J. Robbinspointer returns nonzero if the current locale requires shift states,
66bc0b3a18STim J. Robbinszero otherwise;
67bc0b3a18STim J. Robbinsif shift states are required, the shift state is reset to the initial state.
68bc0b3a18STim J. Robbins.Sh RETURN VALUES
69bc0b3a18STim J. RobbinsIf
70bc0b3a18STim J. Robbins.Fa mbchar
71bc0b3a18STim J. Robbinsis
72bc0b3a18STim J. Robbins.Dv NULL ,
73bc0b3a18STim J. Robbinsthe
74bc0b3a18STim J. Robbins.Fn wctomb
75bc0b3a18STim J. Robbinsfunction returns nonzero if shift states are supported,
76bc0b3a18STim J. Robbinszero otherwise.
77bc0b3a18STim J. RobbinsIf
78bc0b3a18STim J. Robbins.Fa mbchar
79bc0b3a18STim J. Robbinsis valid,
80bc0b3a18STim J. Robbins.Fn wctomb
81bc0b3a18STim J. Robbinsreturns
82bc0b3a18STim J. Robbinsthe number of bytes processed in
83bc0b3a18STim J. Robbins.Fa mbchar ,
84bc0b3a18STim J. Robbinsor \-1 if no multibyte character
85bc0b3a18STim J. Robbinscould be recognized or converted.
868b810927STim J. RobbinsIn this case,
87b9384efcSRuslan Ermilov.Fn wctomb Ns 's
888b810927STim J. Robbinsinternal conversion state is undefined.
89bc0b3a18STim J. Robbins.Sh ERRORS
90bc0b3a18STim J. RobbinsThe
91bc0b3a18STim J. Robbins.Fn wctomb
92bc0b3a18STim J. Robbinsfunction will fail if:
93bc0b3a18STim J. Robbins.Bl -tag -width Er
94bc0b3a18STim J. Robbins.It Bq Er EILSEQ
95bc0b3a18STim J. RobbinsAn invalid multibyte sequence was detected.
968b810927STim J. Robbins.It Bq Er EINVAL
978b810927STim J. RobbinsThe internal conversion state is invalid.
98bc0b3a18STim J. Robbins.El
99bc0b3a18STim J. Robbins.Sh SEE ALSO
100bc0b3a18STim J. Robbins.Xr mbtowc 3 ,
101bc0b3a18STim J. Robbins.Xr wcrtomb 3 ,
102bc0b3a18STim J. Robbins.Xr wcstombs 3 ,
103bc0b3a18STim J. Robbins.Xr wctob 3
104bc0b3a18STim J. Robbins.Sh STANDARDS
105bc0b3a18STim J. RobbinsThe
106bc0b3a18STim J. Robbins.Fn wctomb
107bc0b3a18STim J. Robbinsfunction conforms to
1088b810927STim J. Robbins.St -isoC-99 .
109