OSDN Git Service

(split) LDP: Update original to v3.37.
[linuxjm/LDP_man-pages.git] / original / 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  2011-10-16 "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 .sp
24 .in -4n
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
27 .in
28 .sp
29 .BR wcsnrtombs ():
30 .PD 0
31 .ad l
32 .RS 4
33 .TP 4
34 Since glibc 2.10:
35 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
36 .TP
37 Before glibc 2.10:
38 _GNU_SOURCE
39 .RE
40 .ad
41 .PD
42 .SH DESCRIPTION
43 The
44 .BR wcsnrtombs ()
45 function is like the
46 .BR wcsrtombs (3)
47 function,
48 except that the number of wide characters to be converted,
49 starting at \fI*src\fP, is limited to \fInwc\fP.
50 .PP
51 If \fIdest\fP is not a NULL pointer,
52 the
53 .BR wcsnrtombs ()
54 function converts
55 at most \fInwc\fP wide characters from
56 the wide-character string \fI*src\fP to a multibyte string starting at
57 \fIdest\fP.
58 At most \fIlen\fP bytes are written to \fIdest\fP.
59 The shift state
60 \fI*ps\fP is updated.
61 The conversion is effectively performed by repeatedly
62 calling
63 .IR "wcrtomb(dest, *src, ps)" ,
64 as long as this call succeeds,
65 and then incrementing \fIdest\fP by the
66 number of bytes written and \fI*src\fP
67 by one.
68 The conversion can stop for three reasons:
69 .PP
70 1. A wide character has been encountered that can not be represented as a
71 multibyte sequence (according to the current locale).
72 In this case \fI*src\fP
73 is left pointing to the invalid wide character,
74 .I (size_t)\ \-1
75 is returned,
76 and \fIerrno\fP is set to \fBEILSEQ\fP.
77 .PP
78 2. \fInwc\fP wide characters have been
79 converted without encountering a null wide character (L\(aq\\0\(aq),
80 or the length limit forces a stop.
81 In this case \fI*src\fP is left pointing
82 to the next wide character to be converted, and the number of bytes written
83 to \fIdest\fP is returned.
84 .PP
85 3. The wide-character string has been completely converted, including the
86 terminating null wide character (which has the side effect of bringing back \fI*ps\fP
87 to the initial state).
88 In this case \fI*src\fP is set to NULL, and the number
89 of bytes written to \fIdest\fP,
90 excluding the terminating null byte (\(aq\\0\(aq), is
91 returned.
92 .PP
93 If \fIdest\fP is NULL, \fIlen\fP is ignored,
94 and the conversion proceeds as above,
95 except that the converted bytes are not written out to memory, and that
96 no destination length limit exists.
97 .PP
98 In both of the above cases,
99 if \fIps\fP is a NULL pointer, a static anonymous
100 state only known to the wcsnrtombs function is used instead.
101 .PP
102 The programmer must ensure that there is room for at least \fIlen\fP bytes
103 at \fIdest\fP.
104 .SH "RETURN VALUE"
105 The
106 .BR wcsnrtombs ()
107 function returns
108 the number of bytes that make up the
109 converted part of multibyte sequence,
110 not including the terminating null byte.
111 If a wide character was encountered which
112 could not be converted,
113 .I (size_t)\ \-1
114 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
115 .SH "CONFORMING TO"
116 POSIX.1-2008.
117 .SH NOTES
118 The behavior of
119 .BR wcsnrtombs ()
120 depends on the
121 .B LC_CTYPE
122 category of the
123 current locale.
124 .PP
125 Passing NULL as \fIps\fP is not multithread safe.
126 .SH "SEE ALSO"
127 .BR iconv (3),
128 .BR wcsrtombs (3)