xref: /dragonfly/lib/libc/locale/wcrtomb.3 (revision 74ffc4e3)
10d5acd74SJohn Marino.\" Copyright (c) 2002-2004 Tim J. Robbins
2eee2ef09SJoerg Sonnenberger.\" All rights reserved.
3eee2ef09SJoerg Sonnenberger.\"
4eee2ef09SJoerg Sonnenberger.\" Redistribution and use in source and binary forms, with or without
5eee2ef09SJoerg Sonnenberger.\" modification, are permitted provided that the following conditions
6eee2ef09SJoerg Sonnenberger.\" are met:
7eee2ef09SJoerg Sonnenberger.\" 1. Redistributions of source code must retain the above copyright
8eee2ef09SJoerg Sonnenberger.\"    notice, this list of conditions and the following disclaimer.
9eee2ef09SJoerg Sonnenberger.\" 2. Redistributions in binary form must reproduce the above copyright
10eee2ef09SJoerg Sonnenberger.\"    notice, this list of conditions and the following disclaimer in the
11eee2ef09SJoerg Sonnenberger.\"    documentation and/or other materials provided with the distribution.
12eee2ef09SJoerg Sonnenberger.\"
13eee2ef09SJoerg Sonnenberger.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14eee2ef09SJoerg Sonnenberger.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15eee2ef09SJoerg Sonnenberger.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16eee2ef09SJoerg Sonnenberger.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17eee2ef09SJoerg Sonnenberger.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18eee2ef09SJoerg Sonnenberger.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19eee2ef09SJoerg Sonnenberger.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20eee2ef09SJoerg Sonnenberger.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21eee2ef09SJoerg Sonnenberger.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22eee2ef09SJoerg Sonnenberger.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23eee2ef09SJoerg Sonnenberger.\" SUCH DAMAGE.
24eee2ef09SJoerg Sonnenberger.\"
250d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/locale/wcrtomb.3 250883 2013-05-21 19:59:37Z ed $
260d5acd74SJohn Marino.\"
27*74ffc4e3SSascha Wildner.Dd May 4, 2019
28eee2ef09SJoerg Sonnenberger.Dt WCRTOMB 3
29eee2ef09SJoerg Sonnenberger.Os
30eee2ef09SJoerg Sonnenberger.Sh NAME
310d5acd74SJohn Marino.Nm wcrtomb ,
327d3de48cSSascha Wildner.Nm wcrtomb_l ,
330d5acd74SJohn Marino.Nm c16rtomb ,
34*74ffc4e3SSascha Wildner.Nm c16rtomb_l ,
35*74ffc4e3SSascha Wildner.Nm c32rtomb ,
36*74ffc4e3SSascha Wildner.Nm c32rtomb_l
370d5acd74SJohn Marino.Nd "convert a wide-character code to a character (restartable)"
38eee2ef09SJoerg Sonnenberger.Sh LIBRARY
39eee2ef09SJoerg Sonnenberger.Lb libc
40eee2ef09SJoerg Sonnenberger.Sh SYNOPSIS
41eee2ef09SJoerg Sonnenberger.In wchar.h
42eee2ef09SJoerg Sonnenberger.Ft size_t
430d5acd74SJohn Marino.Fn wcrtomb "char * restrict s" "wchar_t c" "mbstate_t * restrict ps"
440d5acd74SJohn Marino.In uchar.h
450d5acd74SJohn Marino.Ft size_t
460d5acd74SJohn Marino.Fn c16rtomb "char * restrict s" "char16_t c" "mbstate_t * restrict ps"
470d5acd74SJohn Marino.Ft size_t
480d5acd74SJohn Marino.Fn c32rtomb "char * restrict s" "char32_t c" "mbstate_t * restrict ps"
497d3de48cSSascha Wildner.In xlocale.h
507d3de48cSSascha Wildner.Ft size_t
517d3de48cSSascha Wildner.Fn wcrtomb_l "char * restrict s" "wchar_t c" "mbstate_t * restrict ps" "locale_t locale"
52*74ffc4e3SSascha Wildner.Ft size_t
53*74ffc4e3SSascha Wildner.Fn c16rtomb_l "char * restrict s" "char16_t c" "mbstate_t * restrict ps" "locale_t locale"
54*74ffc4e3SSascha Wildner.Ft size_t
55*74ffc4e3SSascha Wildner.Fn c32rtomb_l "char * restrict s" "char32_t c" "mbstate_t * restrict ps" "locale_t"
56eee2ef09SJoerg Sonnenberger.Sh DESCRIPTION
570d5acd74SJohn MarinoThe
580d5acd74SJohn Marino.Fn wcrtomb ,
597d3de48cSSascha Wildner.Fn wcrtomb_l ,
60*74ffc4e3SSascha Wildner.Fn c16rtomb ,
61*74ffc4e3SSascha Wildner.Fn c16rtomb_l ,
62*74ffc4e3SSascha Wildner.Fn c32rtomb ,
630d5acd74SJohn Marinoand
64*74ffc4e3SSascha Wildner.Fn c32rtomb_l
650d5acd74SJohn Marinofunctions store a multibyte sequence representing the
660d5acd74SJohn Marinowide character
670d5acd74SJohn Marino.Fa c ,
680d5acd74SJohn Marinoincluding any necessary shift sequences, to the
690d5acd74SJohn Marinocharacter array
70eee2ef09SJoerg Sonnenberger.Fa s ,
710d5acd74SJohn Marinostoring a maximum of
720d5acd74SJohn Marino.Dv MB_CUR_MAX
730d5acd74SJohn Marinobytes.
74eee2ef09SJoerg Sonnenberger.Pp
750d5acd74SJohn MarinoIf
760d5acd74SJohn Marino.Fa s
770d5acd74SJohn Marinois
780d5acd74SJohn Marino.Dv NULL ,
790d5acd74SJohn Marinothese functions behave as if
800d5acd74SJohn Marino.Fa s
810d5acd74SJohn Marinopointed to an internal buffer and
820d5acd74SJohn Marino.Fa c
830d5acd74SJohn Marinowas a null wide character (L'\e0').
84eee2ef09SJoerg Sonnenberger.Pp
850d5acd74SJohn MarinoThe
860d5acd74SJohn Marino.Ft mbstate_t
870d5acd74SJohn Marinoargument,
880d5acd74SJohn Marino.Fa ps ,
890d5acd74SJohn Marinois used to keep track of the shift state.
900d5acd74SJohn MarinoIf it is
910d5acd74SJohn Marino.Dv NULL ,
920d5acd74SJohn Marinothese functions use an internal, static
930d5acd74SJohn Marino.Vt mbstate_t
940d5acd74SJohn Marinoobject, which is initialized to the initial conversion state
950d5acd74SJohn Marinoat program startup.
960d5acd74SJohn Marino.Pp
970d5acd74SJohn MarinoAs certain multibyte characters may only be represented by a series of
980d5acd74SJohn Marino16-bit characters, the
990d5acd74SJohn Marino.Fn c16rtomb
1000d5acd74SJohn Marinomay need to invoked multiple times before a multibyte sequence is
1010d5acd74SJohn Marinoreturned.
1027d3de48cSSascha Wildner.Pp
1037d3de48cSSascha WildnerThe
104*74ffc4e3SSascha Wildner.Fn wcrtomb_l ,
105*74ffc4e3SSascha Wildner.Fn c16rtomb_l ,
106*74ffc4e3SSascha Wildnerand
107*74ffc4e3SSascha Wildner.Fn c32rtomb_l
108*74ffc4e3SSascha Wildnerfunctions take an explicit
1097d3de48cSSascha Wildner.Fa locale
1107d3de48cSSascha Wildnerargument, whereas the
111*74ffc4e3SSascha Wildner.Fn wcrtomb ,
112*74ffc4e3SSascha Wildner.Fn c16rtomb ,
113*74ffc4e3SSascha Wildnerand
114*74ffc4e3SSascha Wildner.Fn c32rtomb
115*74ffc4e3SSascha Wildnerfunctions use the current global or per-thread locale.
116eee2ef09SJoerg Sonnenberger.Sh RETURN VALUES
1170d5acd74SJohn MarinoThese functions return the length (in bytes) of the multibyte sequence
1180d5acd74SJohn Marinoneeded to represent
1190d5acd74SJohn Marino.Fa c ,
1200d5acd74SJohn Marinoor
1210d5acd74SJohn Marino.Po Vt size_t Pc Ns \-1
1220d5acd74SJohn Marinoif
1230d5acd74SJohn Marino.Fa c
1240d5acd74SJohn Marinois not a valid wide character code.
125eee2ef09SJoerg Sonnenberger.Sh ERRORS
1260d5acd74SJohn MarinoThe
1270d5acd74SJohn Marino.Fn wcrtomb ,
1287d3de48cSSascha Wildner.Fn wcrtomb_l ,
129*74ffc4e3SSascha Wildner.Fn c16rtomb ,
130*74ffc4e3SSascha Wildner.Fn c16rtomb_l ,
131*74ffc4e3SSascha Wildner.Fn c32rtomb ,
1320d5acd74SJohn Marinoand
133*74ffc4e3SSascha Wildner.Fn c32rtomb_l
1340d5acd74SJohn Marinofunctions will fail if:
135eee2ef09SJoerg Sonnenberger.Bl -tag -width Er
136eee2ef09SJoerg Sonnenberger.It Bq Er EILSEQ
1370d5acd74SJohn MarinoAn invalid wide character code was specified.
138eee2ef09SJoerg Sonnenberger.It Bq Er EINVAL
1390d5acd74SJohn MarinoThe conversion state is invalid.
140eee2ef09SJoerg Sonnenberger.El
141eee2ef09SJoerg Sonnenberger.Sh SEE ALSO
1420d5acd74SJohn Marino.Xr mbrtowc 3 ,
1430d5acd74SJohn Marino.Xr multibyte 3 ,
144eee2ef09SJoerg Sonnenberger.Xr setlocale 3 ,
1458a84c799SMatthew Dillon.Xr wcrtombin 3 ,
1468a84c799SMatthew Dillon.Xr wcrtoutf8 3 ,
14740e054f9SSascha Wildner.Xr wctomb 3 ,
1487d3de48cSSascha Wildner.Xr xlocale 3
149eee2ef09SJoerg Sonnenberger.Sh STANDARDS
150eee2ef09SJoerg SonnenbergerThe
1510d5acd74SJohn Marino.Fn wcrtomb ,
1520d5acd74SJohn Marino.Fn c16rtomb
1530d5acd74SJohn Marinoand
1540d5acd74SJohn Marino.Fn c32rtomb
1550d5acd74SJohn Marinofunctions conform to
1560d5acd74SJohn Marino.St -isoC-2011 .
157