xref: /freebsd/lib/libc/locale/mbstowcs.3 (revision 4543ef516683042d46f3bd3bb8a4f3f746e00499)
1.\" Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
2.\" Copyright (c) 1993
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" Donn Seeley of BSDI.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
32.\"
33.Dd April 8, 2004
34.Dt MBSTOWCS 3
35.Os
36.Sh NAME
37.Nm mbstowcs
38.Nd convert a character string to a wide-character string
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In stdlib.h
43.Ft size_t
44.Fo mbstowcs
45.Fa "wchar_t * restrict wcstring" "const char * restrict mbstring"
46.Fa "size_t nwchars"
47.Fc
48.Sh DESCRIPTION
49The
50.Fn mbstowcs
51function converts a multibyte character string
52.Fa mbstring
53beginning in the initial conversion state
54into a wide character string
55.Fa wcstring .
56No more than
57.Fa nwchars
58wide characters are stored.
59A terminating null wide character is appended if there is room.
60.Sh RETURN VALUES
61The
62.Fn mbstowcs
63function returns the number of wide characters converted,
64not counting any terminating null wide character, or \-1
65if an invalid multibyte character was encountered.
66.Sh ERRORS
67The
68.Fn mbstowcs
69function will fail if:
70.Bl -tag -width Er
71.It Bq Er EILSEQ
72An invalid multibyte sequence was detected.
73.It Bq Er EINVAL
74The conversion state is invalid.
75.El
76.Sh SEE ALSO
77.Xr mbsrtowcs 3 ,
78.Xr mbtowc 3 ,
79.Xr multibyte 3
80.Sh STANDARDS
81The
82.Fn mbstowcs
83function conforms to
84.St -isoC-99 .
85