1WCSTOL(P)                  POSIX Programmer's Manual                 WCSTOL(P)
2
3
4

NAME

6       wcstol, wcstoll - convert a wide-character string to a long integer
7

SYNOPSIS

9       #include <wchar.h>
10
11       long wcstol(const wchar_t *restrict nptr, wchar_t **restrict endptr,
12              int base);
13       long long wcstoll(const wchar_t *restrict nptr,
14              wchar_t **restrict endptr, int base);
15
16

DESCRIPTION

18       These functions shall convert the initial portion of the wide-character
19       string pointed to by nptr  to  long,  long  long,  unsigned  long,  and
20       unsigned  long  long  representation,  respectively.  First, they shall
21       decompose the input string into three parts:
22
23        1. An initial, possibly empty, sequence of white-space  wide-character
24           codes (as specified by iswspace())
25
26        2. A  subject  sequence  interpreted as an integer represented in some
27           radix determined by the value of base
28
29        3. A final wide-character string of one  or  more  unrecognized  wide-
30           character codes, including the terminating null wide-character code
31           of the input wide-character string
32
33       Then they shall attempt to convert the subject sequence to an  integer,
34       and return the result.
35
36       If  base  is  0, the expected form of the subject sequence is that of a
37       decimal constant, octal constant, or hexadecimal constant, any of which
38       may  be preceded by a '+' or '-' sign. A decimal constant begins with a
39       non-zero digit, and consists of a sequence of decimal digits. An  octal
40       constant  consists  of the prefix '0' optionally followed by a sequence
41       of the digits '0' to '7' only. A hexadecimal constant consists  of  the
42       prefix  0x  or 0X followed by a sequence of the decimal digits and let‐
43       ters 'a' (or 'A' ) to 'f' (or 'F' ) with values 10 to 15 respectively.
44
45       If the value of base is between 2 and 36, the expected form of the sub‐
46       ject sequence is a sequence of letters and digits representing an inte‐
47       ger with the radix specified by base, optionally preceded by a  '+'  or
48       '-' sign, but not including an integer suffix. The letters from 'a' (or
49       'A' ) to 'z' (or 'Z' ) inclusive are ascribed the values 10 to 35; only
50       letters  whose ascribed values are less than that of base shall be per‐
51       mitted. If the value of base is 16, the wide-character code representa‐
52       tions  of  0x  or 0X may optionally precede the sequence of letters and
53       digits, following the sign if present.
54
55       The subject sequence is defined as the longest initial  subsequence  of
56       the  input  wide-character  string,  starting with the first non-white-
57       space wide-character code that is of the expected  form.   The  subject
58       sequence  contains  no wide-character codes if the input wide-character
59       string is empty or  consists  entirely  of  white-space  wide-character
60       code, or if the first non-white-space wide-character code is other than
61       a sign or a permissible letter or digit.
62
63       If the subject sequence has the  expected  form  and  base  is  0,  the
64       sequence of wide-character codes starting with the first digit shall be
65       interpreted as an integer constant. If the  subject  sequence  has  the
66       expected  form  and  the value of base is between 2 and 36, it shall be
67       used as the base for conversion, ascribing to each letter its value  as
68       given  above.  If  the  subject  sequence begins with a minus sign, the
69       value resulting from the conversion shall be negated. A pointer to  the
70       final wide-character string shall be stored in the object pointed to by
71       endptr, provided that endptr is not a null pointer.
72
73       In other than the C    or POSIX  locales, other  implementation-defined
74       subject sequences may be accepted.
75
76       If the subject sequence is empty or does not have the expected form, no
77       conversion shall be performed; the value of nptr shall be stored in the
78       object  pointed  to  by  endptr,  provided  that  endptr  is not a null
79       pointer.
80
81       These functions shall not change the setting of errno if successful.
82
83       Since 0, {LONG_MIN} or {LLONG_MIN} and {LONG_MAX}  or  {LLONG_MAX}  are
84       returned on error and are also valid returns on success, an application
85       wishing to check for error situations should set errno to 0, then  call
86       wcstol() or wcstoll(), then check errno.
87

RETURN VALUE

89       Upon  successful completion, these functions shall return the converted
90       value, if any. If no conversion could be performed, 0 shall be returned
91        and  errno  may be set to indicate the error.  If the correct value is
92       outside the range  of  representable  values,  {LONG_MIN},  {LONG_MAX},
93       {LLONG_MIN}, or {LLONG_MAX} shall be returned (according to the sign of
94       the value), and errno set to [ERANGE].
95

ERRORS

97       These functions shall fail if:
98
99       EINVAL The value of base is not supported.
100
101       ERANGE The value to be returned is not representable.
102
103
104       These functions may fail if:
105
106       EINVAL No conversion could be performed.
107
108
109       The following sections are informative.
110

EXAMPLES

112       None.
113

APPLICATION USAGE

115       None.
116

RATIONALE

118       None.
119

FUTURE DIRECTIONS

121       None.
122

SEE ALSO

124       iswalpha() , scanf() ,  wcstod()  ,  the  Base  Definitions  volume  of
125       IEEE Std 1003.1-2001, <wchar.h>
126
128       Portions  of  this text are reprinted and reproduced in electronic form
129       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
130       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
131       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
132       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
133       event of any discrepancy between this version and the original IEEE and
134       The  Open Group Standard, the original IEEE and The Open Group Standard
135       is the referee document. The original Standard can be  obtained  online
136       at http://www.opengroup.org/unix/online.html .
137
138
139
140IEEE/The Open Group                  2003                            WCSTOL(P)
Impressum