]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/mbstowcs.3
hyphen/dash fixes
[thirdparty/man-pages.git] / 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 1999-07-25 "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, the \fBmbstowcs\fP function converts the
25 multibyte string \fIsrc\fP to a wide-character string starting at \fIdest\fP.
26 At most \fIn\fP wide characters are written to \fIdest\fP. The conversion starts
27 in the initial state. The conversion can stop for three reasons:
28 .PP
29 1. An invalid multibyte sequence has been encountered. In this case
30 (size_t)(\-1) is returned.
31 .PP
32 2. \fIn\fP non-L'\\0' wide characters have been stored at \fIdest\fP. In this
33 case the number of wide characters written to \fIdest\fP is returned, but the
34 shift state at this point is lost.
35 .PP
36 3. The multibyte string has been completely converted, including the
37 terminating '\\0'. In this case the number of wide characters written to
38 \fIdest\fP, excluding the terminating L'\\0' character, is returned.
39 .PP
40 The programmer must ensure that there is room for at least \fIn\fP wide
41 characters at \fIdest\fP.
42 .PP
43 If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
44 above, except that the converted wide characters are not written out to memory,
45 and that no length limit exists.
46 .PP
47 In order to avoid the case 2 above, the programmer should make sure \fIn\fP is
48 greater or equal to \fImbstowcs(NULL,src,0)+1\fP.
49 .SH "RETURN VALUE"
50 The \fBmbstowcs\fP function returns the number of wide characters that make
51 up the converted part of the wide character string, not including the
52 terminating null wide character. If an invalid multibyte sequence was
53 encountered, (size_t)(\-1) is returned.
54 .SH "CONFORMING TO"
55 ISO/ANSI C, UNIX98
56 .SH "SEE ALSO"
57 .BR mbsrtowcs (3)
58 .SH NOTES
59 The behaviour of \fBmbstowcs\fP depends on the LC_CTYPE category of the
60 current locale.
61 .PP
62 The function \fBmbsrtowcs\fP provides a better interface to the same
63 functionality.