]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/locale/mbsrtowcs.3
libc/locale: don't expose nonexistant __collate_load_error
[FreeBSD/FreeBSD.git] / lib / libc / locale / mbsrtowcs.3
1 .\" Copyright (c) 2002-2004 Tim J. Robbins
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .Dd August 7, 2020
25 .Dt MBSRTOWCS 3
26 .Os
27 .Sh NAME
28 .Nm mbsrtowcs ,
29 .Nm mbsnrtowcs
30 .Nd "convert a character string to a wide-character string (restartable)"
31 .Sh LIBRARY
32 .Lb libc
33 .Sh SYNOPSIS
34 .In wchar.h
35 .Ft size_t
36 .Fo mbsrtowcs
37 .Fa "wchar_t * restrict dst" "const char ** restrict src" "size_t len"
38 .Fa "mbstate_t * restrict ps"
39 .Fc
40 .Ft size_t
41 .Fo mbsnrtowcs
42 .Fa "wchar_t * restrict dst" "const char ** restrict src" "size_t nms"
43 .Fa "size_t len" "mbstate_t * restrict ps"
44 .Fc
45 .Sh DESCRIPTION
46 The
47 .Fn mbsrtowcs
48 function converts a sequence of multibyte characters pointed to indirectly by
49 .Fa src
50 into a sequence of corresponding wide characters and stores at most
51 .Fa len
52 of them in the
53 .Vt wchar_t
54 array pointed to by
55 .Fa dst ,
56 until it encounters a terminating null character
57 .Pq Li '\e0' .
58 .Pp
59 If
60 .Fa dst
61 is
62 .Dv NULL ,
63 no characters are stored.
64 .Pp
65 If
66 .Fa dst
67 is not
68 .Dv NULL ,
69 the pointer pointed to by
70 .Fa src
71 is updated to point to the character after the one that conversion stopped at.
72 If conversion stops because a null character is encountered,
73 .Fa *src
74 is set to
75 .Dv NULL .
76 .Pp
77 The
78 .Vt mbstate_t
79 argument,
80 .Fa ps ,
81 is used to keep track of the shift state.
82 If it is
83 .Dv NULL ,
84 .Fn mbsrtowcs
85 uses an internal, static
86 .Vt mbstate_t
87 object, which is initialized to the initial conversion state
88 at program startup.
89 .Pp
90 The
91 .Fn mbsnrtowcs
92 function behaves identically to
93 .Fn mbsrtowcs ,
94 except that conversion stops after reading at most
95 .Fa nms
96 bytes from the buffer pointed to by
97 .Fa src .
98 .Sh RETURN VALUES
99 If successful, and
100 .Fa dst
101 is not NULL, the
102 .Fn mbsrtowcs
103 and
104 .Fn mbsnrtowcs
105 functions return the number of wide characters stored in
106 the array pointed to by
107 .Fa dst .
108 .Pp
109 If
110 .Fa dst
111 was NULL then the functions
112 .Fn mbsrtowcs
113 and
114 .Fn mbsnrtowcs
115 return the number of wide characters that would have been stored where
116 .Fa dst
117 points to an infinitely large array.
118 .Pp
119 If either one of the functions is not successful then
120 .Po Vt size_t Pc Ns \-1
121 is returned.
122 .Sh ERRORS
123 The
124 .Fn mbsrtowcs
125 and
126 .Fn mbsnrtowcs
127 functions will fail if:
128 .Bl -tag -width Er
129 .It Bq Er EILSEQ
130 An invalid multibyte character sequence was encountered.
131 .It Bq Er EINVAL
132 The conversion state is invalid.
133 .El
134 .Sh SEE ALSO
135 .Xr mbrtowc 3 ,
136 .Xr mbstowcs 3 ,
137 .Xr multibyte 3 ,
138 .Xr wcsrtombs 3
139 .Sh STANDARDS
140 The
141 .Fn mbsrtowcs
142 function conforms to
143 .St -isoC-99 .
144 .Pp
145 The
146 .Fn mbsnrtowcs
147 function is an extension to the standard.