OSDN Git Service

(split) LDP_man-pages: update original to v3.35.
[linuxjm/LDP_man-pages.git] / original / man3 / mbsnrtowcs.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 MBSNRTOWCS 3  2011-10-01 "GNU" "Linux Programmer's Manual"
14 .SH NAME
15 mbsnrtowcs \- convert a multibyte string to a wide-character string
16 .SH SYNOPSIS
17 .nf
18 .B #include <wchar.h>
19 .sp
20 .BI "size_t mbsnrtowcs(wchar_t *" dest ", const char **" src ,
21 .BI "                  size_t " nms ", 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 mbsnrtowcs ():
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 mbsnrtowcs ()
45 function is like the
46 .BR mbsrtowcs (3)
47 function, except that
48 the number of bytes to be converted, starting at \fI*src\fP, is limited to
49 \fInms\fP.
50 .PP
51 If \fIdest\fP is not a NULL pointer, the
52 .BR mbsnrtowcs ()
53 function converts at
54 most \fInms\fP bytes from the
55 multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
56 At most \fIlen\fP wide characters are written to \fIdest\fP.
57 The shift state
58 \fI*ps\fP is updated.
59 The conversion is effectively performed by repeatedly
60 calling
61 .I "mbrtowc(dest, *src, n, ps)"
62 where \fIn\fP is some
63 positive number, as long as this call succeeds, and then incrementing
64 \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
65 The
66 conversion can stop for three reasons:
67 .IP 1. 3
68 An invalid multibyte sequence has been encountered.
69 In this case \fI*src\fP
70 is left pointing to the invalid multibyte sequence,
71 .I (size_t)\ \-1
72 is returned,
73 and \fIerrno\fP is set to \fBEILSEQ\fP.
74 .IP 2.
75 The \fInms\fP limit forces a stop,
76 or \fIlen\fP non-L\(aq\\0\(aq wide characters
77 have been stored at \fIdest\fP.
78 In this case \fI*src\fP is left pointing to the
79 next multibyte sequence to be converted, and the number of wide characters
80 written to \fIdest\fP is returned.
81 .IP 3.
82 The multibyte string has been completely converted, including the
83 terminating null wide character (\(aq\\0\(aq)
84 (which has the side effect of bringing back \fI*ps\fP to the
85 initial state).
86 In this case \fI*src\fP is set to NULL, and the number of wide
87 characters written to \fIdest\fP,
88 excluding the terminating null wide character,
89 is returned.
90 .PP
91 If \fIdest\fP is NULL, \fIlen\fP is ignored, and the conversion proceeds as
92 above, except that the converted wide characters
93 are not written out to memory,
94 and that no destination length limit exists.
95 .PP
96 In both of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
97 state only known to the mbsnrtowcs function is used instead.
98 .PP
99 The programmer must ensure that there is room for at least \fIlen\fP wide
100 characters at \fIdest\fP.
101 .SH "RETURN VALUE"
102 The
103 .BR mbsnrtowcs ()
104 function returns the number of wide characters
105 that make up the converted part of the wide-character string,
106 not including the terminating null wide character.
107 If an invalid multibyte sequence was
108 encountered,
109 .I (size_t)\ \-1
110 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
111 .SH "CONFORMING TO"
112 POSIX.1-2008.
113 .SH NOTES
114 The behavior of
115 .BR mbsnrtowcs ()
116 depends on the
117 .B LC_CTYPE
118 category of the
119 current locale.
120 .PP
121 Passing NULL as \fIps\fP is not multithread safe.
122 .SH "SEE ALSO"
123 .BR iconv (3),
124 .BR mbsrtowcs (3)