OSDN Git Service

(split) LDP: Update original to v3.37.
[linuxjm/LDP_man-pages.git] / original / man3 / wcsrtombs.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 .\"   ISO/IEC 9899:1999
13 .\"
14 .TH WCSRTOMBS 3  2011-10-16 "GNU" "Linux Programmer's Manual"
15 .SH NAME
16 wcsrtombs \- convert a wide-character string to a multibyte string
17 .SH SYNOPSIS
18 .nf
19 .B #include <wchar.h>
20 .sp
21 .BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src ,
22 .BI "                 size_t " len ", mbstate_t *" ps );
23 .fi
24 .SH DESCRIPTION
25 If \fIdest\fP is not a NULL pointer,
26 the
27 .BR wcsrtombs ()
28 function converts
29 the wide-character string \fI*src\fP to a multibyte string starting at
30 \fIdest\fP.
31 At most \fIlen\fP bytes are written to \fIdest\fP.
32 The shift state
33 \fI*ps\fP is updated.
34 The conversion is effectively performed by repeatedly
35 calling
36 .IR "wcrtomb(dest, *src, ps)" ,
37 as long as this call succeeds,
38 and then incrementing \fIdest\fP by the
39 number of bytes written and \fI*src\fP
40 by one.
41 The conversion can stop for three reasons:
42 .PP
43 1. A wide character has been encountered that can not be represented as a
44 multibyte sequence (according to the current locale).
45 In this case \fI*src\fP
46 is left pointing to the invalid wide character,
47 .I (size_t)\ \-1
48 is returned,
49 and
50 .I errno
51 is set to \fBEILSEQ\fP.
52 .PP
53 2. The length limit forces a stop.
54 In this case \fI*src\fP is left pointing
55 to the next wide character to be converted,
56 and the number of bytes written to
57 \fIdest\fP is returned.
58 .PP
59 3. The wide-character string has been completely converted, including the
60 terminating null wide character (L\(aq\\0\(aq),
61 which has the side effect of bringing back \fI*ps\fP
62 to the initial state.
63 In this case \fI*src\fP is set to NULL, and the number
64 of bytes written to \fIdest\fP,
65 excluding the terminating null byte (\(aq\\0\(aq),
66 is returned.
67 .PP
68 If \fIdest\fP is NULL, \fIlen\fP is ignored,
69 and the conversion proceeds as above, except that the converted bytes
70 are not written out to memory, and that
71 no length limit exists.
72 .PP
73 In both of the above cases,
74 if \fIps\fP is a NULL pointer, a static anonymous
75 state only known to the wcsrtombs function is used instead.
76 .PP
77 The programmer must ensure that there is room for at least \fIlen\fP bytes
78 at \fIdest\fP.
79 .SH "RETURN VALUE"
80 The
81 .BR wcsrtombs ()
82 function returns
83 the number of bytes that make up the
84 converted part of multibyte sequence,
85 not including the terminating null byte.
86 If a wide character was encountered
87 which could not be converted,
88 .I (size_t)\ \-1
89 is returned, and
90 .I errno
91 set to \fBEILSEQ\fP.
92 .SH "CONFORMING TO"
93 C99.
94 .SH NOTES
95 The behavior of
96 .BR wcsrtombs ()
97 depends on the
98 .B LC_CTYPE
99 category of the
100 current locale.
101 .PP
102 Passing NULL as \fIps\fP is not multithread safe.
103 .SH "SEE ALSO"
104 .BR iconv (3),
105 .BR wcsnrtombs (3),
106 .BR wcstombs (3)