.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
.\" ISO/IEC 9899:1999
.\"
-.TH MBTOWC 3 2011-09-28 "GNU" "Linux Programmer's Manual"
+.TH MBTOWC 3 2014-03-18 "GNU" "Linux Programmer's Manual"
.SH NAME
mbtowc \- convert a multibyte sequence to a wide character
.SH SYNOPSIS
.BI "int mbtowc(wchar_t *" pwc ", const char *" s ", size_t " n );
.fi
.SH DESCRIPTION
-The main case for this function is when \fIs\fP is not NULL and \fIpwc\fP is
+The main case for this function is when
+.IR s
+is not NULL and
+.I pwc
+is
not NULL.
In this case, the
.BR mbtowc ()
-function inspects at most \fIn\fP
-bytes of the multibyte string starting at \fIs\fP,
+function inspects at most
+.I n
+bytes of the multibyte string starting at
+.IR s ,
extracts the next complete
multibyte character, converts it to a wide character and stores it at
-\fI*pwc\fP.
-It updates an internal shift state only known to the mbtowc
+.IR *pwc .
+It updates an internal shift state known only to the
+.BR mbtowc ()
function.
-If \fIs\fP does not point to a null byte (\(aq\\0\(aq), it returns the number
-of bytes that were consumed from \fIs\fP, otherwise it returns 0.
+If
+.I s
+does not point to a null byte (\(aq\\0\(aq), it returns the number
+of bytes that were consumed from
+.IR s ,
+otherwise it returns 0.
.PP
-If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
+If the
+.IR n
+bytes starting at
+.I s
+do not contain a complete multibyte
character, or if they contain an invalid multibyte sequence,
.BR mbtowc ()
returns \-1.
-This can happen even if \fIn\fP >= \fIMB_CUR_MAX\fP,
+This can happen even if
+.I n
+>=
+.IR MB_CUR_MAX ,
if the multibyte string contains redundant shift sequences.
.PP
-A different case is when \fIs\fP is not NULL but \fIpwc\fP is NULL.
-In this
-case the
+A different case is when
+.IR s
+is not NULL but
+.I pwc
+is NULL.
+In this case, the
.BR mbtowc ()
function behaves as above, except that it does not
store the converted wide character in memory.
.PP
-A third case is when \fIs\fP is NULL.
-In this case, \fIpwc\fP and \fIn\fP are
+A third case is when
+.I s
+is NULL.
+In this case,
+.IR pwc
+and
+.I n
+are
ignored.
The
.BR mbtowc ()
returns nonzero if the encoding has nontrivial shift state, or zero if the
encoding is stateless.
.SH RETURN VALUE
-If \fIs\fP is not NULL, the
+If
+.I s
+is not NULL, the
.BR mbtowc ()
function returns the number of
-consumed bytes starting at \fIs\fP, or 0 if \fIs\fP points to a null byte,
+consumed bytes starting at
+.IR s ,
+or 0 if
+.I s
+points to a null byte,
or \-1 upon failure.
.PP
-If \fIs\fP is NULL, the
+If
+.I s
+is NULL, the
.BR mbtowc ()
function
returns nonzero if the encoding
a better interface to the same functionality.
.SH SEE ALSO
.BR MB_CUR_MAX (3),
+.BR mblen (3),
.BR mbrtowc (3),
-.BR mbstowcs (3)
+.BR mbstowcs (3),
+.BR wctomb (3),
+.BR wcstombs (3)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.