DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

wcstol(3C)


wcstol -- convert a wide character string to a long integer

Synopsis

#include <wchar.h>

long wcstol(const wchar_t *nptr, wchar_t **endptr, int base);

long long wcstoll(const wchar_t *nptr, wchar_t **endptr, int base);

unsigned long wcstoul(const wchar_t *nptr, wchar_t **endptr, int base);

unsigned long long wcstoul(const wchar_t *nptr, wchar_t **endptr, int base);

Description

wcstoll- convert a wide character string to a long long integer

wcstoul- convert a wide character string to an unsigned long integer

wcstoull- convert a wide character string to an unsigned long long integer

wcstol returns, as a long integer, the value represented by the character string pointed to by nptr. wcstoul returns, as an unsigned long integer, the value represented by the character string pointed to by nptr. The string is scanned up to the first character inconsistent with the base. Leading ``white-space'' characters [as defined by iswspace] are ignored.

If the value of endptr is not a null pointer, a pointer to the wide character terminating the scan is returned in the location pointed to by endptr. If no integer can be formed, that location is set to nptr, and zero is returned.

If base is between 2 and 36, inclusive, it is used as the base for conversion. After an optional leading sign, leading zeros are ignored, and a leading ``0x'' or ``0X'' is ignored if base is 16 and a leading 0b or 0B is ignored if base is 2.

If base is zero, the string itself determines the base as follows: After an optional leading sign a leading zero indicates octal conversion, and a leading ``0x'' or ``0X'' hexadecimal conversion. Otherwise, decimal conversion is used.

wcstoll and wcstoull are similar functions that return a long long or unsigned long long, respectively.

Return values

For wcstol, if the value represented by nptr would cause overflow, LONG_MAX or LONG_MIN is returned (according to the sign of the value), and errno is set to the value ERANGE.

For wcstoul, if the value represented by nptr would cause overflow, ULONG_MAX is returned, and errno is set to the value ERANGE.

If wcstol or wcstoul is given a base other than zero or 2 through 36, it returns zero and sets errno to EINVAL. Otherwise, wcstol and wcstoul return the represented value.

Errors

In the following conditions, wcstol fails and sets errno to:

EINVAL
The value of base is not supported.

EINVAL
No conversion could be performed.

ERANGE
The value to be returned is not representable.

References

fscanf(3S), wchar(5), wcstod(3C)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004