OSDN Git Service

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