OSDN Git Service

(split) LDP: Support po4a.
[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-09-28 "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, excluding the terminating null, is returned.
65 .PP
66 If \fIdest\fP is NULL, \fIlen\fP is ignored,
67 and the conversion proceeds as above, except that the converted bytes
68 are not written out to memory, and that
69 no length limit exists.
70 .PP
71 In both of the above cases,
72 if \fIps\fP is a NULL pointer, a static anonymous
73 state only known to the wcsrtombs function is used instead.
74 .PP
75 The programmer must ensure that there is room for at least \fIlen\fP bytes
76 at \fIdest\fP.
77 .SH "RETURN VALUE"
78 The
79 .BR wcsrtombs ()
80 function returns
81 the number of bytes that make up the
82 converted part of multibyte sequence,
83 not including the terminating null byte.
84 If a wide character was encountered
85 which could not be converted,
86 .I (size_t)\ \-1
87 is returned, and
88 .I errno
89 set to \fBEILSEQ\fP.
90 .SH "CONFORMING TO"
91 C99.
92 .SH NOTES
93 The behavior of
94 .BR wcsrtombs ()
95 depends on the
96 .B LC_CTYPE
97 category of the
98 current locale.
99 .PP
100 Passing NULL as \fIps\fP is not multithread safe.
101 .SH "SEE ALSO"
102 .BR iconv (3),
103 .BR wcsnrtombs (3),
104 .BR wcstombs (3)