xref: /dflybsd-src/lib/libc/locale/wctomb.3 (revision c66c7e2fb8d0d28477d550f1d2a50c4677d547ff)
10d5acd74SJohn Marino.\" Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
20d5acd74SJohn Marino.\" Copyright (c) 1993
30d5acd74SJohn Marino.\"	The Regents of the University of California.  All rights reserved.
4eee2ef09SJoerg Sonnenberger.\"
50d5acd74SJohn Marino.\" This code is derived from software contributed to Berkeley by
60d5acd74SJohn Marino.\" Donn Seeley of BSDI.
7eee2ef09SJoerg Sonnenberger.\"
8eee2ef09SJoerg Sonnenberger.\" Redistribution and use in source and binary forms, with or without
9eee2ef09SJoerg Sonnenberger.\" modification, are permitted provided that the following conditions
10eee2ef09SJoerg Sonnenberger.\" are met:
11eee2ef09SJoerg Sonnenberger.\" 1. Redistributions of source code must retain the above copyright
12eee2ef09SJoerg Sonnenberger.\"    notice, this list of conditions and the following disclaimer.
13eee2ef09SJoerg Sonnenberger.\" 2. Redistributions in binary form must reproduce the above copyright
14eee2ef09SJoerg Sonnenberger.\"    notice, this list of conditions and the following disclaimer in the
15eee2ef09SJoerg Sonnenberger.\"    documentation and/or other materials provided with the distribution.
16*c66c7e2fSzrj.\" 3. Neither the name of the University nor the names of its contributors
170d5acd74SJohn Marino.\"    may be used to endorse or promote products derived from this software
180d5acd74SJohn Marino.\"    without specific prior written permission.
19eee2ef09SJoerg Sonnenberger.\"
200d5acd74SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21eee2ef09SJoerg Sonnenberger.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22eee2ef09SJoerg Sonnenberger.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
230d5acd74SJohn Marino.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24eee2ef09SJoerg Sonnenberger.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25eee2ef09SJoerg Sonnenberger.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26eee2ef09SJoerg Sonnenberger.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27eee2ef09SJoerg Sonnenberger.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28eee2ef09SJoerg Sonnenberger.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29eee2ef09SJoerg Sonnenberger.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30eee2ef09SJoerg Sonnenberger.\" SUCH DAMAGE.
31eee2ef09SJoerg Sonnenberger.\"
320d5acd74SJohn Marino.\" From @(#)multibyte.3	8.1 (Berkeley) 6/4/93
330d5acd74SJohn Marino.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
340d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/locale/wctomb.3 165903 2007-01-09 00:28:16Z imp $
350d5acd74SJohn Marino.\"
367d3de48cSSascha Wildner.Dd December 27, 2013
37eee2ef09SJoerg Sonnenberger.Dt WCTOMB 3
38eee2ef09SJoerg Sonnenberger.Os
39eee2ef09SJoerg Sonnenberger.Sh NAME
407d3de48cSSascha Wildner.Nm wctomb ,
417d3de48cSSascha Wildner.Nm wctomb_l
420d5acd74SJohn Marino.Nd convert a wide-character code to a character
43eee2ef09SJoerg Sonnenberger.Sh LIBRARY
44eee2ef09SJoerg Sonnenberger.Lb libc
45eee2ef09SJoerg Sonnenberger.Sh SYNOPSIS
46eee2ef09SJoerg Sonnenberger.In stdlib.h
47eee2ef09SJoerg Sonnenberger.Ft int
480d5acd74SJohn Marino.Fn wctomb "char *mbchar" "wchar_t wchar"
497d3de48cSSascha Wildner.In xlocale.h
507d3de48cSSascha Wildner.Ft int
517d3de48cSSascha Wildner.Fn wctomb_l "char *mbchar" "wchar_t wchar" "locale_t locale"
52eee2ef09SJoerg Sonnenberger.Sh DESCRIPTION
53eee2ef09SJoerg SonnenbergerThe
54eee2ef09SJoerg Sonnenberger.Fn wctomb
557d3de48cSSascha Wildnerand
567d3de48cSSascha Wildner.Fn wctomb_l
577d3de48cSSascha Wildnerfunctions convert a wide character
58eee2ef09SJoerg Sonnenberger.Fa wchar
597d3de48cSSascha Wildnerinto a multibyte character and store
600d5acd74SJohn Marinothe result in
610d5acd74SJohn Marino.Fa mbchar .
620d5acd74SJohn MarinoThe object pointed to by
630d5acd74SJohn Marino.Fa mbchar
640d5acd74SJohn Marinomust be large enough to accommodate the multibyte character, which
650d5acd74SJohn Marinomay be up to
660d5acd74SJohn Marino.Dv MB_LEN_MAX
670d5acd74SJohn Marinobytes.
68eee2ef09SJoerg Sonnenberger.Pp
690d5acd74SJohn MarinoA call with a null
700d5acd74SJohn Marino.Fa mbchar
710d5acd74SJohn Marinopointer returns nonzero if the current locale requires shift states,
720d5acd74SJohn Marinozero otherwise;
730d5acd74SJohn Marinoif shift states are required, the shift state is reset to the initial state.
747d3de48cSSascha Wildner.Pp
757d3de48cSSascha WildnerThe
767d3de48cSSascha Wildner.Fn wctomb_l
777d3de48cSSascha Wildnerfunction takes an explicit
787d3de48cSSascha Wildner.Fa locale
797d3de48cSSascha Wildnerargument, whereas the
807d3de48cSSascha Wildner.Fn wctomb
817d3de48cSSascha Wildnerfunction uses the current global or per-thread locale.
82eee2ef09SJoerg Sonnenberger.Sh RETURN VALUES
83eee2ef09SJoerg SonnenbergerIf
840d5acd74SJohn Marino.Fa mbchar
850d5acd74SJohn Marinois
86eee2ef09SJoerg Sonnenberger.Dv NULL ,
870d5acd74SJohn Marinothe
880d5acd74SJohn Marino.Fn wctomb
897d3de48cSSascha Wildnerand
907d3de48cSSascha Wildner.Fn wctomb_l
917d3de48cSSascha Wildnerfunctions return nonzero if shift states are supported,
920d5acd74SJohn Marinozero otherwise.
930d5acd74SJohn MarinoIf
940d5acd74SJohn Marino.Fa mbchar
950d5acd74SJohn Marinois valid,
960d5acd74SJohn Marino.Fn wctomb
977d3de48cSSascha Wildnerand
987d3de48cSSascha Wildner.Fn wctomb_l
997d3de48cSSascha Wildnerreturn
1000d5acd74SJohn Marinothe number of bytes processed in
1010d5acd74SJohn Marino.Fa mbchar ,
1020d5acd74SJohn Marinoor \-1 if no multibyte character
1030d5acd74SJohn Marinocould be recognized or converted.
1040d5acd74SJohn MarinoIn this case,
1050d5acd74SJohn Marino.Fn wctomb Ns 's
1067d3de48cSSascha Wildnerand
1077d3de48cSSascha Wildner.Fn wctomb_l Ns 's
1087d3de48cSSascha Wildnerinternal conversion states are undefined.
109eee2ef09SJoerg Sonnenberger.Sh ERRORS
1100d5acd74SJohn MarinoThe
1110d5acd74SJohn Marino.Fn wctomb
1127d3de48cSSascha Wildnerand
1137d3de48cSSascha Wildner.Fn wctomb_l
1147d3de48cSSascha Wildnerfunctions will fail if:
1150d5acd74SJohn Marino.Bl -tag -width Er
1160d5acd74SJohn Marino.It Bq Er EILSEQ
1170d5acd74SJohn MarinoAn invalid multibyte sequence was detected.
1180d5acd74SJohn Marino.It Bq Er EINVAL
1190d5acd74SJohn MarinoThe internal conversion state is invalid.
1200d5acd74SJohn Marino.El
121eee2ef09SJoerg Sonnenberger.Sh SEE ALSO
1220d5acd74SJohn Marino.Xr mbtowc 3 ,
1230d5acd74SJohn Marino.Xr wcrtomb 3 ,
1240d5acd74SJohn Marino.Xr wcstombs 3 ,
1257d3de48cSSascha Wildner.Xr wctob 3 ,
1267d3de48cSSascha Wildner.Xr xlocale 3
127eee2ef09SJoerg Sonnenberger.Sh STANDARDS
128eee2ef09SJoerg SonnenbergerThe
129eee2ef09SJoerg Sonnenberger.Fn wctomb
130eee2ef09SJoerg Sonnenbergerfunction conforms to
1310d5acd74SJohn Marino.St -isoC-99 .
132