Unleashed v1.4
[unleashed.git] / share / man / man3c / wcstoul.3c
blob5cd23733f267332a305c8c7f6047abf4afc2fa23
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
45 .\"
46 .TH WCSTOUL 3C "Nov 1, 2003"
47 .SH NAME
48 wcstoul, wcstoull \- convert wide-character string to unsigned long
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <wchar.h>
54 \fBunsigned long\fR  \fBwcstoul\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
55      \fBwchar_t **restrict\fR \fIendptr\fR, \fBint\fR \fIbase\fR);
56 .fi
58 .LP
59 .nf
60 \fBunsigned long long\fR \fBwcstoull\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
61      \fBwchar_t **restrict\fR \fIendptr\fR, \fBint\fR \fIbase\fR);
62 .fi
64 .SH DESCRIPTION
65 .sp
66 .LP
67 The \fBwcstoul()\fR and \fBwcstoull()\fR functions convert the initial portion
68 of the wide-character string pointed to by \fInptr\fR to \fBunsigned long\fR
69 and \fBunsigned long long\fR representation, respectively. First they decompose
70 the input wide-character string  into three parts:
71 .RS +4
72 .TP
74 An initial, possibly empty, sequence of white-space wide-character codes (as
75 specified by the function \fBiswspace\fR(3C))
76 .RE
77 .RS +4
78 .TP
80  Asubject sequence interpreted as an integer represented in some radix
81 determined by the value of \fIbase\fR
82 .RE
83 .RS +4
84 .TP
86 a final wide-character string of one or more unrecognized wide-character
87 codes, including the terminating null wide-character code of the input wide
88 character string
89 .RE
90 .sp
91 .LP
92 They then attempt to convert the subject sequence to an unsigned integer and
93 return the result.
94 .sp
95 .LP
96 If the value of \fIbase\fR is 0, the expected form of the subject sequence is
97 that of a decimal constant, an octal constant, or a hexadecimal constant, any
98 of which may be preceded by a `+' or a `\(mi' sign. A decimal constant begins
99 with a non-zero digit, and consists of a sequence of decimal digits. An octal
100 constant consists of the prefix `0', optionally followed by a sequence of the
101 digits `0' to `7' only. A hexadecimal constant consists of the prefix `0x' or
102 `0X', followed by a sequence of the decimal digits and letters `a' (or `A') to
103 `f' (or `F'), with values 10 to 15, respectively.
106 If the value of \fIbase\fR is between 2 and 36, the expected form of the
107 subject sequence is a sequence of letters and digits representing an integer
108 with the radix specified by  \fIbase\fR, optionally preceded by a `+' or a
109 `\(mi' sign, but not including an integer suffix. The letters from `a' (or `A')
110 to `z' (or `Z') inclusive are ascribed the values 10 to 35; only letters whose
111 ascribed values are less than that of \fIbase\fR are permitted. If the value of
112 \fIbase\fR is 16, the wide-character codes `0x' or `0X' may optionally precede
113 the sequence of letters and digits, following the sign, if present.
116 The subject sequence is defined as the longest initial subsequence of the input
117 wide-character string, starting with the first wide-character code that is not
118 a white space and is of the expected form. The subject sequence contains no
119 wide-character codes if the input wide-character string is empty or consists
120 entirely of white-space wide-character codes, or if the first wide-character
121 code that is not a white space  is other than a sign or a permissible letter or
122 digit.
125 If the subject sequence has the expected form and the value of \fIbase\fR is 0,
126 the sequence of wide-character codes starting with the first digit is
127 interpreted as an integer constant. If the subject sequence has the expected
128 form and the value of \fIbase\fR is between 2 and 36, it is used as the base
129 for conversion, ascribing to each letter its value as given above. If the
130 subject sequence begins with a minus sign, the value resulting from the
131 conversion is negated. A pointer to the final wide character string is  stored
132 in the object pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a
133 null pointer.
136 If the subject sequence is empty or does not have the expected form, no
137 conversion is performed; the value of \fInptr\fR is stored in the object
138 pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a null pointer.
141 The \fBwcstoul()\fR function does not change the setting of \fBerrno\fR if
142 successful.
145 Since 0, {\fBULONG_MAX\fR}, and {\fBULLONG_MAX\fR} are returned on error and 0
146 is also a valid return on success, an application wanting to check for error
147 situations should set \fBerrno\fR to 0, then call \fBwcstoul()\fR or
148 \fBwcstoull()\fR, then check  \fBerrno\fR.
151 The \fBwcstoul()\fR and \fBwcstoull()\fR functions do not change the setting of
152 \fBerrno\fR if successful.
153 .SH RETURN VALUE
156 Upon successful completion, \fBwcstoul()\fR and \fBwcstoull()\fR return the
157 converted value, if any. If no conversion could be performed, \fB0\fR is
158 returned and \fBerrno\fR may be set to indicate the error. If the correct value
159 is outside the range of representable values, {\fBULONG_MAX\fR} or
160 {\fBULLONG_MAX\fR}, respectively, is returned and \fBerrno\fR is set to
161 \fBERANGE\fR.
162 .SH ERRORS
165 The \fBwcstoul()\fR and \fBwcstoull()\fR functions will fail if:
167 .ne 2
169 \fB\fBEINVAL\fR\fR
171 .RS 10n
172 The value of \fIbase\fR is not supported.
176 .ne 2
178 \fB\fBERANGE\fR\fR
180 .RS 10n
181 The value to be returned is not representable.
186 The \fBwcstoul()\fR and \fBwcstoull()\fR functions may fail if:
188 .ne 2
190 \fB\fBEINVAL\fR\fR
192 .RS 10n
193 No conversion could be performed.
196 .SH USAGE
199 Unlike \fBwcstod\fR(3C) and \fBwcstol\fR(3C), \fBwcstoul()\fR and
200 \fBwcstoull()\fR must always return a non-negative number; using the return
201 value of \fBwcstoul()\fR for out-of-range numbers with \fBwcstoul()\fR or
202 \fBwcstoull()\fR could cause more severe problems than just loss of precision
203 if those numbers can ever be negative.
204 .SH ATTRIBUTES
207 See \fBattributes\fR(5) for descriptions of the following attributes:
212 box;
213 l | l
214 l | l .
215 ATTRIBUTE TYPE  ATTRIBUTE VALUE
217 Interface Stability     Standard
219 MT-Level        MT-Safe
222 .SH SEE ALSO
225 \fBisspace\fR(3C), \fBiswalpha\fR(3C), \fBscanf\fR(3C), \fBwcstod\fR(3C),
226 \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)