]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/wcsnrtombs.3
Convert to American spelling conventions
[thirdparty/man-pages.git] / man3 / wcsnrtombs.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
10 .\" Dinkumware C library reference http://www.dinkumware.com/
11 .\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
12 .\"
13 .TH WCSNRTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
14 .SH NAME
15 wcsnrtombs \- convert a wide-character string to a multibyte string
16 .SH SYNOPSIS
17 .nf
18 .B #include <wchar.h>
19 .sp
20 .BI "size_t wcsnrtombs(char *" dest ", const wchar_t **" src ", size_t " nwc ,
21 .BI " size_t " len ", mbstate_t *" ps );
22 .fi
23 .SH DESCRIPTION
24 The
25 .BR wcsnrtombs ()
26 function is like the
27 .BR wcsrtombs ()
28 function,
29 except that the number of wide characters to be converted,
30 starting at \fI*src\fP, is limited to \fInwc\fP.
31 .PP
32 If \fIdest\fP is not a NULL pointer,
33 the
34 .BR wcsnrtombs ()
35 function converts
36 at most \fInwc\fP wide characters from
37 the wide-character string \fI*src\fP to a multibyte string starting at
38 \fIdest\fP.
39 At most \fIlen\fP bytes are written to \fIdest\fP.
40 The shift state
41 \fI*ps\fP is updated.
42 The conversion is effectively performed by repeatedly
43 calling wcrtomb(\fIdest\fP,\fI*src\fP,\fIps\fP),
44 as long as this call succeeds,
45 and then incrementing \fIdest\fP by the
46 number of bytes written and \fI*src\fP
47 by one.
48 The conversion can stop for three reasons:
49 .PP
50 1. A wide character has been encountered that can not be represented as a
51 multibyte sequence (according to the current locale).
52 In this case \fI*src\fP
53 is left pointing to the invalid wide character, (size_t)(\-1) is returned,
54 and \fIerrno\fP is set to \fBEILSEQ\fP.
55 .PP
56 2. \fInwc\fP wide characters have been
57 converted without encountering a L'\\0',
58 or the length limit forces a stop.
59 In this case \fI*src\fP is left pointing
60 to the next wide character to be converted, and the number of bytes written
61 to \fIdest\fP is returned.
62 .PP
63 3. The wide-character string has been completely converted, including the
64 terminating L'\\0' (which has the side effect of bringing back \fI*ps\fP
65 to the initial state).
66 In this case \fI*src\fP is set to NULL, and the number
67 of bytes written to \fIdest\fP, excluding the terminating '\\0' byte, is
68 returned.
69 .PP
70 If \fIdest\fP is NULL, \fIlen\fP is ignored,
71 and the conversion proceeds as above,
72 except that the converted bytes are not written out to memory, and that
73 no destination length limit exists.
74 .PP
75 In both of the above cases,
76 if \fIps\fP is a NULL pointer, a static anonymous
77 state only known to the wcsnrtombs function is used instead.
78 .PP
79 The programmer must ensure that there is room for at least \fIlen\fP bytes
80 at \fIdest\fP.
81 .SH "RETURN VALUE"
82 The
83 .BR wcsnrtombs ()
84 function returns
85 the number of bytes that make up the
86 converted part of multibyte sequence,
87 not including the terminating null byte.
88 If a wide character was encountered which
89 could not be converted, (size_t)(\-1)
90 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
91 .SH "CONFORMING TO"
92 This function is a GNU extension.
93 .SH NOTES
94 The behavior of
95 .BR wcsnrtombs ()
96 depends on the LC_CTYPE category of the
97 current locale.
98 .PP
99 Passing NULL as \fIps\fP is not multi-thread safe.
100 .SH "SEE ALSO"
101 .BR iconv (3),
102 .BR wcsrtombs (3)