Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/mbstowcs.html
2024-02-19 00:21:47 -05:00

151 lines
6.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>mbstowcs</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="mbstowcs"></a> <a name="tag_03_363"></a><!-- mbstowcs -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_363_01"></a>NAME</h4>
<blockquote>mbstowcs - convert a character string to a wide-character string</blockquote>
<h4><a name="tag_03_363_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>#include &lt;<a href="../basedefs/stdlib.h.html">stdlib.h</a>&gt;<br>
<br>
size_t mbstowcs(wchar_t *restrict</tt> <i>pwcs</i><tt>, const char *restrict</tt> <i>s</i><tt>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_t</tt> <i>n</i><tt>);<br>
</tt></code></p>
</blockquote>
<h4><a name="tag_03_363_03"></a>DESCRIPTION</h4>
<blockquote>
<div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
border="0"> The functionality described on this reference page is aligned with the ISO&nbsp;C standard. Any conflict between the
requirements described here and the ISO&nbsp;C standard is unintentional. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defers to
the ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div>
<p>The <i>mbstowcs</i>() function shall convert a sequence of characters that begins in the initial shift state from the array
pointed to by <i>s</i> into a sequence of corresponding wide-character codes and shall store not more than <i>n</i> wide-character
codes into the array pointed to by <i>pwcs</i>. No characters that follow a null byte (which is converted into a wide-character
code with value 0) shall be examined or converted. Each character shall be converted as if by a call to <a href=
"../functions/mbtowc.html"><i>mbtowc</i>()</a>, except that the shift state of <a href=
"../functions/mbtowc.html"><i>mbtowc</i>()</a> is not affected.</p>
<p>No more than <i>n</i> elements shall be modified in the array pointed to by <i>pwcs</i>. If copying takes place between objects
that overlap, the behavior is undefined.</p>
<p>The behavior of this function shall be affected by the <i>LC_CTYPE</i> category of the current locale. <sup>[<a href=
"javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;If
<i>pwcs</i> is a null pointer, <i>mbstowcs</i>() shall return the length required to convert the entire array regardless of the
value of <i>n</i>, but no values are stored. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_03_363_04"></a>RETURN VALUE</h4>
<blockquote>
<p>If an invalid character is encountered, <i>mbstowcs</i>() shall return (<b>size_t</b>)-1 <sup>[<a href=
"javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and may set
<i>errno</i> to indicate the error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>Otherwise, <i>mbstowcs</i>() shall return the number of the array elements modified <sup>[<a href=
"javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;(or required
if <i>pwcs</i> is null), <img src="../images/opt-end.gif" alt="[Option End]" border="0"> not including a terminating 0 code, if
any. The array shall not be zero-terminated if the value returned is <i>n</i>.</p>
</blockquote>
<h4><a name="tag_03_363_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>mbstowcs</i>() function may fail if:</p>
<dl compact>
<dt>[EILSEQ]</dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Invalid byte sequence is detected. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_363_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_363_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_363_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_363_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_363_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="mblen.html"><i>mblen</i>()</a> , <a href="mbtowc.html"><i>mbtowc</i>()</a> , <a href="wctomb.html"><i>wctomb</i>()</a>
, <a href="wcstombs.html"><i>wcstombs</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/stdlib.h.html"><i>&lt;stdlib.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_363_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 4. Aligned with the ISO&nbsp;C standard.</p>
</blockquote>
<h4><a name="tag_03_363_12"></a>Issue 6</h4>
<blockquote>
<p>The <i>mbstowcs</i>() prototype is updated for alignment with the ISO/IEC&nbsp;9899:1999 standard.</p>
<p>Extensions beyond the ISO&nbsp;C standard are marked.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>