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