xref: /netbsd-src/lib/libc/locale/wcstombs.3 (revision 7d564f115ec52be567acffa45b37d350edd606f8)
1*7d564f11Smbalmer.\" $NetBSD: wcstombs.3,v 1.13 2011/03/16 09:32:12 mbalmer Exp $
28625ada8Stshiozak.\"
38625ada8Stshiozak.\" Copyright (c)2002 Citrus Project,
48625ada8Stshiozak.\" All rights reserved.
58625ada8Stshiozak.\"
68625ada8Stshiozak.\" Redistribution and use in source and binary forms, with or without
78625ada8Stshiozak.\" modification, are permitted provided that the following conditions
88625ada8Stshiozak.\" are met:
98625ada8Stshiozak.\" 1. Redistributions of source code must retain the above copyright
108625ada8Stshiozak.\"    notice, this list of conditions and the following disclaimer.
118625ada8Stshiozak.\" 2. Redistributions in binary form must reproduce the above copyright
128625ada8Stshiozak.\"    notice, this list of conditions and the following disclaimer in the
138625ada8Stshiozak.\"    documentation and/or other materials provided with the distribution.
148625ada8Stshiozak.\"
158625ada8Stshiozak.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
168625ada8Stshiozak.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
178625ada8Stshiozak.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
188625ada8Stshiozak.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
198625ada8Stshiozak.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
208625ada8Stshiozak.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
218625ada8Stshiozak.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
228625ada8Stshiozak.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
238625ada8Stshiozak.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
248625ada8Stshiozak.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
258625ada8Stshiozak.\" SUCH DAMAGE.
268625ada8Stshiozak.\"
27*7d564f11Smbalmer.Dd March 16, 2011
288625ada8Stshiozak.Dt WCSTOMBS 3
298625ada8Stshiozak.Os
308625ada8Stshiozak.\" ----------------------------------------------------------------------
318625ada8Stshiozak.Sh NAME
328625ada8Stshiozak.Nm wcstombs
333d3c5d42Swiz.Nd converts a wide-character string to a multibyte character string
348625ada8Stshiozak.\" ----------------------------------------------------------------------
358625ada8Stshiozak.Sh LIBRARY
368625ada8Stshiozak.Lb libc
378625ada8Stshiozak.\" ----------------------------------------------------------------------
388625ada8Stshiozak.Sh SYNOPSIS
39472351e1Swiz.In stdlib.h
408625ada8Stshiozak.Ft size_t
418d8d8b95Stnozaki.Fn wcstombs "char * restrict s" "const wchar_t * restrict pwcs" "size_t n"
428625ada8Stshiozak.\" ----------------------------------------------------------------------
438625ada8Stshiozak.Sh DESCRIPTION
448625ada8Stshiozak.Fn wcstombs
453d3c5d42Swizconverts the nul-terminated wide-character string pointed to by
468625ada8Stshiozak.Fa pwcs
478625ada8Stshiozakto the corresponding multibyte character string,
48cef0afe9Swizand stores it in the array pointed to by
498625ada8Stshiozak.Fa s .
508625ada8StshiozakThis function may modify the first at most
518625ada8Stshiozak.Fa n
52cef0afe9Swizbytes of the array pointed to by
538625ada8Stshiozak.Fa s .
54be85fac5SjmmvEach character will be converted as if
558625ada8Stshiozak.Xr wctomb 3
568625ada8Stshiozakis continuously called, except the internal state of
578625ada8Stshiozak.Xr wctomb 3
588625ada8Stshiozakwill not be affected.
598625ada8Stshiozak.Pp
608625ada8StshiozakFor state-dependent encoding, the
618625ada8Stshiozak.Fn wcstombs
62cef0afe9Swizimplies the result multibyte character string pointed to by
638625ada8Stshiozak.Fa s
648625ada8Stshiozakalways to begin with an initial state.
658625ada8Stshiozak.Pp
66cef0afe9SwizThe behaviour of
678625ada8Stshiozak.Fn wcstombs
68cef0afe9Swizis affected by the
69cef0afe9Swiz.Dv LC_CTYPE
70cef0afe9Swizcategory of the current locale.
718625ada8Stshiozak.Pp
72cef0afe9SwizThese are the special cases:
738625ada8Stshiozak.Bl -tag -width 012345678901
748625ada8Stshiozak.It s == NULL
758625ada8StshiozakThe
768625ada8Stshiozak.Fn wcstombs
778625ada8Stshiozakreturns the number of bytes to store the whole multibyte character string
783d3c5d42Swizcorresponding to the wide-character string pointed to by
798625ada8Stshiozak.Fa pwcs .
808625ada8StshiozakIn this case,
818625ada8Stshiozak.Fa n
828625ada8Stshiozakis ignored.
838625ada8Stshiozak.It pwcs == NULL
84cef0afe9SwizUndefined (may cause the program to crash).
858625ada8Stshiozak.El
868625ada8Stshiozak.\" ----------------------------------------------------------------------
878625ada8Stshiozak.Sh RETURN VALUES
888625ada8Stshiozak.Fn wcstombs
898625ada8Stshiozakreturns:
908625ada8Stshiozak.Bl -tag -width 012345678901
91bf790e3bSyamt.It 0 or positive
92cef0afe9SwizNumber of bytes stored in the array pointed to by
938625ada8Stshiozak.Fa s .
94cef0afe9SwizThere are no cases that the value returned is greater than
958625ada8Stshiozak.Fa n
968625ada8Stshiozak(unless
978625ada8Stshiozak.Fa s
98aba3ac5cSwizis a null pointer).
998625ada8StshiozakIf the return value is equal to
1008625ada8Stshiozak.Fa n ,
101cef0afe9Swizthe string pointed to by
1028625ada8Stshiozak.Fa s
103f80b3487Swizwill not be nul-terminated.
1048625ada8Stshiozak.It (size_t)-1
1058625ada8Stshiozak.Fa pwcs
106cef0afe9Swizpoints to a string containing an invalid wide character.
1078625ada8Stshiozak.Fn wcstombs
108cef0afe9Swizalso sets
109cef0afe9Swiz.Va errno
110cef0afe9Swizto indicate the error.
1118625ada8Stshiozak.El
1128625ada8Stshiozak.\" ----------------------------------------------------------------------
1138625ada8Stshiozak.Sh ERRORS
1148625ada8Stshiozak.Fn wcstombs
115cef0afe9Swizmay cause an error in the following case:
1168625ada8Stshiozak.Bl -tag -width Er
1178625ada8Stshiozak.It Bq Er EILSEQ
1188625ada8Stshiozak.Fa pwcs
119cef0afe9Swizpoints to a string containing an invalid wide character.
1208625ada8Stshiozak.El
1218625ada8Stshiozak.\" ----------------------------------------------------------------------
1228625ada8Stshiozak.Sh SEE ALSO
123*7d564f11Smbalmer.Xr mbstowcs 3 ,
1248625ada8Stshiozak.Xr setlocale 3 ,
1259f64fab4Swiz.Xr wctomb 3
1268625ada8Stshiozak.\" ----------------------------------------------------------------------
1278625ada8Stshiozak.Sh STANDARDS
1288625ada8StshiozakThe
1298625ada8Stshiozak.Fn wcstombs
1308625ada8Stshiozakfunction conforms to
1318625ada8Stshiozak.St -ansiC .
1328625ada8StshiozakThe restrict qualifier is added at
133dca9ccd3Swiz.St -isoC-99 .
134