1WCSTOL(3P) POSIX Programmer's Manual WCSTOL(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 wcstol, wcstoll - convert a wide-character string to a long integer
13
15 #include <wchar.h>
16
17 long wcstol(const wchar_t *restrict nptr, wchar_t **restrict endptr,
18 int base);
19 long long wcstoll(const wchar_t *restrict nptr,
20 wchar_t **restrict endptr, int base);
21
22
24 These functions shall convert the initial portion of the wide-character
25 string pointed to by nptr to long, long long, unsigned long, and
26 unsigned long long representation, respectively. First, they shall
27 decompose the input string into three parts:
28
29 1. An initial, possibly empty, sequence of white-space wide-character
30 codes (as specified by iswspace())
31
32 2. A subject sequence interpreted as an integer represented in some
33 radix determined by the value of base
34
35 3. A final wide-character string of one or more unrecognized wide-
36 character codes, including the terminating null wide-character code
37 of the input wide-character string
38
39 Then they shall attempt to convert the subject sequence to an integer,
40 and return the result.
41
42 If base is 0, the expected form of the subject sequence is that of a
43 decimal constant, octal constant, or hexadecimal constant, any of which
44 may be preceded by a '+' or '-' sign. A decimal constant begins with a
45 non-zero digit, and consists of a sequence of decimal digits. An octal
46 constant consists of the prefix '0' optionally followed by a sequence
47 of the digits '0' to '7' only. A hexadecimal constant consists of the
48 prefix 0x or 0X followed by a sequence of the decimal digits and let‐
49 ters 'a' (or 'A' ) to 'f' (or 'F' ) with values 10 to 15 respectively.
50
51 If the value of base is between 2 and 36, the expected form of the sub‐
52 ject sequence is a sequence of letters and digits representing an inte‐
53 ger with the radix specified by base, optionally preceded by a '+' or
54 '-' sign, but not including an integer suffix. The letters from 'a' (or
55 'A' ) to 'z' (or 'Z' ) inclusive are ascribed the values 10 to 35; only
56 letters whose ascribed values are less than that of base shall be per‐
57 mitted. If the value of base is 16, the wide-character code representa‐
58 tions of 0x or 0X may optionally precede the sequence of letters and
59 digits, following the sign if present.
60
61 The subject sequence is defined as the longest initial subsequence of
62 the input wide-character string, starting with the first non-white-
63 space wide-character code that is of the expected form. The subject
64 sequence contains no wide-character codes if the input wide-character
65 string is empty or consists entirely of white-space wide-character
66 code, or if the first non-white-space wide-character code is other than
67 a sign or a permissible letter or digit.
68
69 If the subject sequence has the expected form and base is 0, the
70 sequence of wide-character codes starting with the first digit shall be
71 interpreted as an integer constant. If the subject sequence has the
72 expected form and the value of base is between 2 and 36, it shall be
73 used as the base for conversion, ascribing to each letter its value as
74 given above. If the subject sequence begins with a minus sign, the
75 value resulting from the conversion shall be negated. A pointer to the
76 final wide-character string shall be stored in the object pointed to by
77 endptr, provided that endptr is not a null pointer.
78
79 In other than the C or POSIX locales, other implementation-defined
80 subject sequences may be accepted.
81
82 If the subject sequence is empty or does not have the expected form, no
83 conversion shall be performed; the value of nptr shall be stored in the
84 object pointed to by endptr, provided that endptr is not a null
85 pointer.
86
87 These functions shall not change the setting of errno if successful.
88
89 Since 0, {LONG_MIN} or {LLONG_MIN} and {LONG_MAX} or {LLONG_MAX} are
90 returned on error and are also valid returns on success, an application
91 wishing to check for error situations should set errno to 0, then call
92 wcstol() or wcstoll(), then check errno.
93
95 Upon successful completion, these functions shall return the converted
96 value, if any. If no conversion could be performed, 0 shall be returned
97 and errno may be set to indicate the error. If the correct value is
98 outside the range of representable values, {LONG_MIN}, {LONG_MAX},
99 {LLONG_MIN}, or {LLONG_MAX} shall be returned (according to the sign of
100 the value), and errno set to [ERANGE].
101
103 These functions shall fail if:
104
105 EINVAL The value of base is not supported.
106
107 ERANGE The value to be returned is not representable.
108
109
110 These functions may fail if:
111
112 EINVAL No conversion could be performed.
113
114
115 The following sections are informative.
116
118 None.
119
121 None.
122
124 None.
125
127 None.
128
130 iswalpha(), scanf(), wcstod(), the Base Definitions volume of
131 IEEE Std 1003.1-2001, <wchar.h>
132
134 Portions of this text are reprinted and reproduced in electronic form
135 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
136 -- Portable Operating System Interface (POSIX), The Open Group Base
137 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
138 Electrical and Electronics Engineers, Inc and The Open Group. In the
139 event of any discrepancy between this version and the original IEEE and
140 The Open Group Standard, the original IEEE and The Open Group Standard
141 is the referee document. The original Standard can be obtained online
142 at http://www.opengroup.org/unix/online.html .
143
144
145
146IEEE/The Open Group 2003 WCSTOL(3P)