blob: 4db548b6b8f802a27fa8c8abe40182b8ccb4dc14 [file]
<html lang="en">
<head>
<title>wcstombs - 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="system.html#system" title="system">
<link rel="next" href="wctomb.html#wctomb" title="wctomb">
<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="wcstombs"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="wctomb.html#wctomb">wctomb</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="system.html#system">system</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.46 <code>wcstombs</code>&mdash;minimal wide char string to multibyte string converter</h3>
<p><a name="index-wcstombs-108"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdlib.h&gt;
size_t wcstombs(char *<var>s</var>, const wchar_t *<var>pwc</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>wcstombs</code>. In this case,
all wide-characters are expected to represent single bytes and so
are converted simply by casting to char.
<p>When _MB_CAPABLE is defined, this routine calls <code>_wcstombs_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>wcstombs</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
wide-char characters does not represent a valid multi-byte character;
otherwise it returns the minimum of: <code>n</code> or the
number of bytes that are transferred to <code>s</code>, not including the
nul terminator.
<p>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 if
<code>n</code> &gt; 0.
<p><br>
<strong>Portability</strong><br>
<code>wcstombs</code> is required in the ANSI C standard. However, the precise
effects vary with the locale.
<p><code>wcstombs</code> requires no supporting OS subroutines.
<p><br>
</body></html>