1wcstoul(3C)              Standard C Library Functions              wcstoul(3C)
2
3
4

NAME

6       wcstoul, wcstoull - convert wide-character string to unsigned long
7

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

102       Upon successful completion, wcstoul() and wcstoull()  return  the  con‐
103       verted  value,  if  any.  If  no  conversion  could  be performed, 0 is
104       returned and errno may be set to indicate the  error.  If  the  correct
105       value  is  outside  the  range  of representable values, {ULONG_MAX} or
106       {ULLONG_MAX}, respectively, is returned and errno is set to ERANGE.
107

ERRORS

109       The wcstoul() and wcstoull() functions will fail if:
110
111       EINVAL    The value of base is not supported.
112
113
114       ERANGE    The value to be returned is not representable.
115
116
117
118       The wcstoul() and wcstoull() functions may fail if:
119
120       EINVAL    No conversion could be performed.
121
122

USAGE

124       Unlike wcstod(3C) and wcstol(3C), wcstoul() and wcstoull() must  always
125       return  a  non-negative number; using the return value of wcstoul() for
126       out-of-range numbers with wcstoul()  or  wcstoull()  could  cause  more
127       severe  problems  than just loss of precision if those numbers can ever
128       be negative.
129

ATTRIBUTES

131       See attributes(5) for descriptions of the following attributes:
132
133
134
135
136       ┌─────────────────────────────┬─────────────────────────────┐
137       │ATTRIBUTE TYPE               │ATTRIBUTE VALUE              │
138       ├─────────────────────────────┼─────────────────────────────┤
139       │Interface Stability          │Standard                     │
140       ├─────────────────────────────┼─────────────────────────────┤
141       │MT-Level                     │MT-Safe                      │
142       └─────────────────────────────┴─────────────────────────────┘
143

SEE ALSO

145       isspace(3C),   iswalpha(3C),   scanf(3C),    wcstod(3C),    wcstol(3C),
146       attributes(5), standards(5)
147
148
149
150SunOS 5.11                        1 Nov 2003                       wcstoul(3C)
Impressum