OSDN Git Service

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