OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / man3 / mbstowcs.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 MBSTOWCS 3  2011-09-10 "GNU" "Linux Programmer's Manual"
15 .SH NAME
16 mbstowcs \- convert a multibyte string to a wide-character string
17 .SH SYNOPSIS
18 .nf
19 .B #include <stdlib.h>
20 .sp
21 .BI "size_t mbstowcs(wchar_t *" dest ", const char *" src ", size_t " n );
22 .fi
23 .SH DESCRIPTION
24 If \fIdest\fP is not a NULL pointer,
25 the
26 .BR mbstowcs ()
27 function converts the
28 multibyte string \fIsrc\fP to a wide-character string starting at \fIdest\fP.
29 At most \fIn\fP wide characters are written to \fIdest\fP.
30 The conversion starts
31 in the initial state.
32 The conversion can stop for three reasons:
33 .IP 1. 3
34 An invalid multibyte sequence has been encountered.
35 In this case
36 .I (size_t)\ \-1
37 is returned.
38 .IP 2.
39 \fIn\fP non-L\(aq\\0\(aq wide characters have been stored at \fIdest\fP.
40 In this
41 case the number of wide characters written to \fIdest\fP is returned, but the
42 shift state at this point is lost.
43 .IP 3.
44 The multibyte string has been completely converted, including the
45 terminating \(aq\\0\(aq.
46 In this case the number of wide characters written to
47 \fIdest\fP, excluding the terminating L\(aq\\0\(aq character, is returned.
48 .PP
49 The programmer must ensure that there is room for at least \fIn\fP wide
50 characters at \fIdest\fP.
51 .PP
52 If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
53 above, except that the converted wide characters are not written out to memory,
54 and that no length limit exists.
55 .PP
56 In order to avoid the case 2 above, the programmer should make sure \fIn\fP is
57 greater or equal to \fImbstowcs(NULL,src,0)+1\fP.
58 .SH "RETURN VALUE"
59 The
60 .BR mbstowcs ()
61 function returns the number of wide characters that make
62 up the converted part of the wide-character string, not including the
63 terminating null wide character.
64 If an invalid multibyte sequence was
65 encountered,
66 .I (size_t)\ \-1
67 is returned.
68 .SH "CONFORMING TO"
69 C99.
70 .SH NOTES
71 The behavior of
72 .BR mbstowcs ()
73 depends on the
74 .B LC_CTYPE
75 category of the
76 current locale.
77 .PP
78 The function
79 .BR mbsrtowcs (3)
80 provides a better interface to the same
81 functionality.
82 .SH "SEE ALSO"
83 .BR mbsrtowcs (3),
84 .BR wcstombs(3)