blob: 391a5e95761ac9313563c2e967d61fae0ed390cd [file]
<html lang="en">
<head>
<title>mbstowcs - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
<link rel="prev" href="mbsrtowcs.html#mbsrtowcs" title="mbsrtowcs">
<link rel="next" href="mblen.html#mblen" title="mblen">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="mbstowcs"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="mblen.html#mblen">mblen</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="mbsrtowcs.html#mbsrtowcs">mbsrtowcs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.28 <code>mbstowcs</code>&mdash;minimal multibyte string to wide char converter</h3>
<p><a name="index-mbstowcs-62"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdlib.h&gt;
int mbstowcs(wchar_t *<var>pwc</var>, const char *<var>s</var>, size_t <var>n</var>);
</pre>
<p><strong>Description</strong><br>
When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
implementation of <code>mbstowcs</code>. In this case, the
only &ldquo;multi-byte character sequences&rdquo; recognized are single bytes,
and they are &ldquo;converted&rdquo; to wide-char versions simply by byte
extension.
<p>When _MB_CAPABLE is defined, this routine calls <code>_mbstowcs_r</code> to perform
the conversion, passing a state variable to allow state dependent
decoding. The result is based on the locale setting which may
be restricted to a defined set of locales.
<p><br>
<strong>Returns</strong><br>
This implementation of <code>mbstowcs</code> returns <code>0</code> if
<var>s</var> is <code>NULL</code> or is the empty string;
it returns <code>-1</code> if _MB_CAPABLE and one of the
multi-byte characters is invalid or incomplete;
otherwise it returns the minimum of: <code>n</code> or the
number of multi-byte characters in <code>s</code> plus 1 (to
compensate for the nul character).
If the return value is -1, the state of the <code>pwc</code> string is
indeterminate. If the input has a length of 0, the output
string will be modified to contain a wchar_t nul terminator.
<p><br>
<strong>Portability</strong><br>
<code>mbstowcs</code> is required in the ANSI C standard. However, the precise
effects vary with the locale.
<p><code>mbstowcs</code> requires no supporting OS subroutines.
<p><br>
</body></html>