1WCSTOUL(P) POSIX Programmer's Manual WCSTOUL(P)
2
3
4
6 wcstoul, wcstoull - convert a wide-character string to an unsigned long
7
9 #include <wchar.h>
10
11 unsigned long wcstoul(const wchar_t *restrict nptr,
12 wchar_t **restrict endptr, int base);
13 unsigned long long wcstoull(const wchar_t *restrict nptr,
14 wchar_t **restrict endptr, int base);
15
16
18 The wcstoul() and wcstoull() functions shall convert the initial por‐
19 tion of the wide-character string pointed to by nptr to unsigned long
20 and unsigned long long representation, respectively. First, they shall
21 decompose the input wide-character 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 unsigned
34 integer, 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 codes 0x or 0X
52 may optionally precede the sequence of letters and digits, following
53 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 wide-character
57 code that is not white space and 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 codes, or if the first wide-character code that is not white space is
61 other than 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 The wcstoul() function shall not change the setting of errno if suc‐
82 cessful.
83
84 Since 0, {ULONG_MAX}, and {ULLONG_MAX} are returned on error and 0 is
85 also a valid return on success, an application wishing to check for
86 error situations should set errno to 0, then call wcstoul() or
87 wcstoull(), then check errno.
88
90 Upon successful completion, the wcstoul() and wcstoull() functions
91 shall return the converted value, if any. If no conversion could be
92 performed, 0 shall be returned and errno may be set to indicate the
93 error. If the correct value is outside the range of representable val‐
94 ues, {ULONG_MAX} or {ULLONG_MAX} respectively shall be returned and
95 errno set to [ERANGE].
96
98 These functions shall fail if:
99
100 EINVAL The value of base is not supported.
101
102 ERANGE The value to be returned is not representable.
103
104
105 These functions may fail if:
106
107 EINVAL No conversion could be performed.
108
109
110 The following sections are informative.
111
113 None.
114
116 None.
117
119 None.
120
122 None.
123
125 iswalpha() , scanf() , wcstod() , wcstol() , the Base Definitions vol‐
126 ume of IEEE Std 1003.1-2001, <wchar.h>
127
129 Portions of this text are reprinted and reproduced in electronic form
130 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
131 -- Portable Operating System Interface (POSIX), The Open Group Base
132 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
133 Electrical and Electronics Engineers, Inc and The Open Group. In the
134 event of any discrepancy between this version and the original IEEE and
135 The Open Group Standard, the original IEEE and The Open Group Standard
136 is the referee document. The original Standard can be obtained online
137 at http://www.opengroup.org/unix/online.html .
138
139
140
141IEEE/The Open Group 2003 WCSTOUL(P)