OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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  2007-07-26 "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 #define _GNU_SOURCE
19 .B #include <wchar.h>
20 .sp
21 .BI "size_t wcsnrtombs(char *" dest ", const wchar_t **" src ", size_t " nwc ,
22 .BI "                  size_t " len ", mbstate_t *" ps );
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR wcsnrtombs ()
27 function is like the
28 .BR wcsrtombs (3)
29 function,
30 except that the number of wide characters to be converted,
31 starting at \fI*src\fP, is limited to \fInwc\fP.
32 .PP
33 If \fIdest\fP is not a NULL pointer,
34 the
35 .BR wcsnrtombs ()
36 function converts
37 at most \fInwc\fP wide characters from
38 the wide-character string \fI*src\fP to a multibyte string starting at
39 \fIdest\fP.
40 At most \fIlen\fP bytes are written to \fIdest\fP.
41 The shift state
42 \fI*ps\fP is updated.
43 The conversion is effectively performed by repeatedly
44 calling
45 .IR "wcrtomb(dest, *src, ps)" ,
46 as long as this call succeeds,
47 and then incrementing \fIdest\fP by the
48 number of bytes written and \fI*src\fP
49 by one.
50 The conversion can stop for three reasons:
51 .PP
52 1. A wide character has been encountered that can not be represented as a
53 multibyte sequence (according to the current locale).
54 In this case \fI*src\fP
55 is left pointing to the invalid wide character,
56 .I (size_t)\ \-1
57 is returned,
58 and \fIerrno\fP is set to \fBEILSEQ\fP.
59 .PP
60 2. \fInwc\fP wide characters have been
61 converted without encountering a L\(aq\\0\(aq,
62 or the length limit forces a stop.
63 In this case \fI*src\fP is left pointing
64 to the next wide character to be converted, and the number of bytes written
65 to \fIdest\fP is returned.
66 .PP
67 3. The wide-character string has been completely converted, including the
68 terminating L\(aq\\0\(aq (which has the side effect of bringing back \fI*ps\fP
69 to the initial state).
70 In this case \fI*src\fP is set to NULL, and the number
71 of bytes written to \fIdest\fP, excluding the terminating \(aq\\0\(aq byte, is
72 returned.
73 .PP
74 If \fIdest\fP is NULL, \fIlen\fP is ignored,
75 and the conversion proceeds as above,
76 except that the converted bytes are not written out to memory, and that
77 no destination length limit exists.
78 .PP
79 In both of the above cases,
80 if \fIps\fP is a NULL pointer, a static anonymous
81 state only known to the wcsnrtombs function is used instead.
82 .PP
83 The programmer must ensure that there is room for at least \fIlen\fP bytes
84 at \fIdest\fP.
85 .SH "RETURN VALUE"
86 The
87 .BR wcsnrtombs ()
88 function returns
89 the number of bytes that make up the
90 converted part of multibyte sequence,
91 not including the terminating null byte.
92 If a wide character was encountered which
93 could not be converted,
94 .I (size_t)\ \-1
95 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
96 .SH "CONFORMING TO"
97 This function is a GNU extension.
98 .SH NOTES
99 The behavior of
100 .BR wcsnrtombs ()
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 wcsrtombs (3)