mbrtowc.html
来自「unix 下的C开发手册,还用详细的例程。」· HTML 代码 · 共 153 行
HTML
153 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>mbrtowc</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_529"> </a>NAME</h4><blockquote>mbrtowc - convert a character to a wide-character code (restartable)</blockquote><h4><a name = "tag_000_007_530"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="wchar.h.html">wchar.h</a>>size_t mbrtowc(wchar_t *<i>pwc</i>, const char *<i>s</i>, size_t <i>n</i>, mbstate_t *<i>ps</i>);</code></pre></blockquote><h4><a name = "tag_000_007_531"> </a>DESCRIPTION</h4><blockquote>If<i>s</i>is a null pointer, the<i>mbrtowc()</i>function is equivalent to the call:<pre><code>mbrtowc(NULL, "", 1, ps)</code></pre><p>In this case, the values of the arguments<i>pwc</i>and<i>n</i>are ignored.<p>If<i>s</i>is not a null pointer, the<i>mbrtowc()</i>function inspects at most<i>n</i>bytes beginning at the byte pointed to by <i>s</i>to determine the number of bytes needed to complete the next character (including any shift sequences). If the function determinesthat the next character is completed, it determines thevalue of the corresponding wide-character and then, if<i>pwc</i>is not a null pointer, stores that value in the object pointed to by<i>pwc</i>.If the corresponding wide-character is the null wide-character, theresulting state described is the initial conversion state.<p>If<i>ps</i>is a null pointer, the<i>mbrtowc()</i>function uses its own internal<b>mbstate_t</b>object, which is initialised at program startup to the initialconversion state. Otherwise, the <b>mbstate_t</b>object pointed to by<i>ps</i>is used to completely describe the current conversion state of theassociated character sequence.The implementation will behave as if no function defined in thisspecification calls<i>mbrtowc()</i>.<p>The behaviour of this function is affected by the LC_CTYPE category ofthe current locale. </blockquote><h4><a name = "tag_000_007_532"> </a>RETURN VALUE</h4><blockquote>The<i>mbrtowc()</i>function returns the first of the following that applies:<dl compact><dt>0<dd>If the next<i>n</i>or fewer bytes complete the character that corresponds tothe null wide-character (which is the value stored).<dt><i>positive</i><dd>If the next<i>n</i>or fewer bytes complete a valid character (which is thevalue stored); the valuereturned is the number of bytes that complete the character.<dt><b>(size_t)-2</b><dd>If the next<i>n</i>bytes contribute to an incomplete but potentially valid character, and all<i>n</i>bytes have been processed (no value is stored). When<i>n</i>has at least the value of the MB_CUR_MAX macro, this case can onlyoccur if <i>s</i>points at a sequence of redundant shift sequences (for implementationswith state-dependent encodings).<dt><b>(size_t)-1</b><dd>If an encoding error occurs, in which case the next<i>n</i>or fewer bytes do not contribute to a complete and valid character (no value is stored). In this case, EILSEQ is stored in<i>errno</i>and the conversion state is undefined.</dl></blockquote><h4><a name = "tag_000_007_533"> </a>ERRORS</h4><blockquote>The<i>mbrtowc()</i>function may fail if:<dl compact><dt>[EINVAL]<dd><i>ps</i>points to an object that contains an invalid conversion state.<dt>[EILSEQ]<dd>Invalid character sequence is detected.</dl></blockquote><h4><a name = "tag_000_007_534"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_535"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_536"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_537"> </a>SEE ALSO</h4><blockquote><i><a href="mbsinit.html">mbsinit()</a></i>,<i><a href="wchar.h.html"><wchar.h></a></i>.<br></blockquote><h4>DERIVATION</h4><blockquote>Derived from the ISO/IEC 9899:1990/Amendment 1:1995 (E).</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?