OSDN Git Service

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