📄 wcstol.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-2003 The Open Group, All Rights Reserved --><title>wcstol</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="wcstol"></a> <a name="tag_03_845"></a><!-- wcstol --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_845_01"></a>NAME</h4><blockquote>wcstol, wcstoll - convert a wide-character string to a long integer</blockquote><h4><a name="tag_03_845_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include <<a href="../basedefs/wchar.h.html">wchar.h</a>><br><br> long wcstol(const wchar_t *restrict</tt> <i>nptr</i><tt>, wchar_t **restrict</tt> <i>endptr</i><tt>,<br> int</tt> <i>base</i><tt>);<br> long long wcstoll(const wchar_t *restrict</tt> <i>nptr</i><tt>,<br> wchar_t **restrict</tt> <i>endptr</i><tt>, int</tt> <i>base</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_845_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 C standard. Any conflict between therequirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers tothe ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>These functions shall convert the initial portion of the wide-character string pointed to by <i>nptr</i> to <b>long</b>, <b>longlong</b>, <b>unsigned long</b>, and <b>unsigned long long</b> representation, respectively. First, they shall decompose the inputstring into three parts:</p><ol><li><p>An initial, possibly empty, sequence of white-space wide-character codes (as specified by <a href="../functions/iswspace.html"><i>iswspace</i>()</a>)</p></li><li><p>A subject sequence interpreted as an integer represented in some radix determined by the value of <i>base</i></p></li><li><p>A final wide-character string of one or more unrecognized wide-character codes, including the terminating null wide-charactercode of the input wide-character string</p></li></ol><p>Then they shall attempt to convert the subject sequence to an integer, and return the result.</p><p>If <i>base</i> is 0, the expected form of the subject sequence is that of a decimal constant, octal constant, or hexadecimalconstant, any of which may be preceded by a <tt>'+'</tt> or <tt>'-'</tt> sign. A decimal constant begins with a non-zero digit, andconsists of a sequence of decimal digits. An octal constant consists of the prefix <tt>'0'</tt> optionally followed by a sequenceof the digits <tt>'0'</tt> to <tt>'7'</tt> only. A hexadecimal constant consists of the prefix 0x or 0X followed by a sequence ofthe decimal digits and letters <tt>'a'</tt> (or <tt>'A'</tt> ) to <tt>'f'</tt> (or <tt>'F'</tt> ) with values 10 to 15respectively.</p><p>If the value of <i>base</i> is between 2 and 36, the expected form of the subject sequence is a sequence of letters and digitsrepresenting an integer with the radix specified by <i>base</i>, optionally preceded by a <tt>'+'</tt> or <tt>'-'</tt> sign, butnot including an integer suffix. The letters from <tt>'a'</tt> (or <tt>'A'</tt> ) to <tt>'z'</tt> (or <tt>'Z'</tt> ) inclusive areascribed the values 10 to 35; only letters whose ascribed values are less than that of <i>base</i> shall be permitted. If the valueof <i>base</i> is 16, the wide-character code representations of 0x or 0X may optionally precede the sequence of letters anddigits, following the sign if present.</p><p>The subject sequence is defined as the longest initial subsequence of the input wide-character string, starting with the firstnon-white-space wide-character code that is of the expected form. The subject sequence contains no wide-character codes if theinput wide-character string is empty or consists entirely of white-space wide-character code, or if the first non-white-spacewide-character code is other than a sign or a permissible letter or digit.</p><p>If the subject sequence has the expected form and <i>base</i> is 0, the sequence of wide-character codes starting with the firstdigit shall be interpreted as an integer constant. If the subject sequence has the expected form and the value of <i>base</i> isbetween 2 and 36, it shall be used as the base for conversion, ascribing to each letter its value as given above. If the subjectsequence begins with a minus sign, the value resulting from the conversion shall be negated. A pointer to the final wide-characterstring shall be stored in the object pointed to by <i>endptr</i>, provided that <i>endptr</i> is not a null pointer.</p><p>In other than the C <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or POSIX <img src="../images/opt-end.gif" alt="[Option End]" border="0"> locales, otherimplementation-defined subject sequences may be accepted.</p><p>If the subject sequence is empty or does not have the expected form, no conversion shall be performed; the value of <i>nptr</i>shall be stored in the object pointed to by <i>endptr</i>, provided that <i>endptr</i> is not a null pointer.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">These functions shall not change the setting of <i>errno</i> if successful.</p><p>Since 0, {LONG_MIN} or {LLONG_MIN} and {LONG_MAX} or {LLONG_MAX} are returned on error and are also valid returns on success, anapplication wishing to check for error situations should set <i>errno</i> to 0, then call <i>wcstol</i>() or <i>wcstoll</i>(), thencheck <i>errno</i>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_845_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, these functions shall return the converted value, if any. If no conversion could be performed, 0shall be returned <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> and <i>errno</i> may be set to indicate the error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"> If the correct value is outside the range of representable values, {LONG_MIN}, {LONG_MAX}, {LLONG_MIN}, or {LLONG_MAX} shallbe returned (according to the sign of the value), and <i>errno</i> set to [ERANGE].</p></blockquote><h4><a name="tag_03_845_05"></a>ERRORS</h4><blockquote><p>These functions shall fail if:</p><dl compact><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The value of <i>base</i> is not supported. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ERANGE]</dt><dd>The value to be returned is not representable.</dd></dl><p>These functions may fail if:</p><dl compact><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Noconversion could be performed. <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_845_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_845_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_845_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_845_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_845_10"></a>SEE ALSO</h4><blockquote><p><a href="iswalpha.html"><i>iswalpha</i>()</a> , <a href="scanf.html"><i>scanf</i>()</a> , <a href="wcstod.html"><i>wcstod</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/wchar.h.html"><i><wchar.h></i></a></p></blockquote><h4><a name="tag_03_845_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4. Derived from the MSE working draft.</p></blockquote><h4><a name="tag_03_845_12"></a>Issue 5</h4><blockquote><p>The DESCRIPTION is updated to indicate that <i>errno</i> is not changed if the function is successful.</p></blockquote><h4><a name="tag_03_845_13"></a>Issue 6</h4><blockquote><p>Extensions beyond the ISO C standard are marked.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>In the RETURN VALUE and ERRORS sections, the [EINVAL] optional error condition is added if no conversion could be performed.</p></li></ul><p>The following changes are made for alignment with the ISO/IEC 9899:1999 standard:</p><ul><li><p>The <i>wcstol</i>() prototype is updated.</p></li><li><p>The <i>wcstoll</i>() function is added.</p></li></ul></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -