Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > W

wcstol(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

wcstol(), wcstoll(), wcstoul(), wcstoull() — convert wide character string to long integer

SYNOPSIS

#include <wchar.h>

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

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

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

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

Remarks

These functions are compliant with the XPG4 Worldwide Portability Interface wide-character formatting functions. They parallel the 8-bit character formatting functions defined in strtol(3C).

DESCRIPTION

wcstol() or wcstoul() converts the wide character string pointed to by nptr to long int or unsigned long int representation, respectively. wcstoll() or wcstoull() converts the wide character string pointed to by nptr to long long or unsigned long long representation, respectively. The wide character string is scanned up to the first wide character inconsistent with the base. Leading "white-space" wide characters (as defined by iswspace() in wctype(3C)) are ignored. If no conversion can take place, zero is returned.

If base is greater than or equal to 2 and less than or equal to 36, it is used as the base for conversion. After an optional leading sign, leading zeros are ignored, and 0x or 0X is ignored if base is 16.

If base is zero, the wide character string itself determines the base as follows: after an optional leading sign, a leading zero indicates octal conversion; a leading 0x or 0X indicates hexadecimal conversion. Otherwise, decimal conversion is used.

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

Definitions for these functions and the type wchar_t are provided in the <wchar.h> header file.

EXTERNAL INFLUENCES

Locale

The LC_CTYPE category determines how wide character codes are interpreted.

International Code Set Support

Single- and multi-byte character code sets are supported.

RETURN VALUE

Upon successful completion, both functions return the converted value, if any.

If the correct value would cause overflow:

wcstol()

returns LONG_MAX or LONG_MIN (according to the sign of the value), and sets errno to ERANGE,

wcstoul()

returns ULONG_MAX and sets errno to ERANGE,

wcstoll()

returns LLONG_MAX or LLONG_MIN (according to the sign of the value), and sets errno to ERANGE,

wcstoull()

returns ULLONG_MAX and sets errno to ERANGE.

For all other errors, zero is returned and errno is set to indicate the error.

ERRORS

wcstol(), wcstoul(), wcstoll(), and wcstoull() fail and errno is set, if any of the following conditions are encountered:

EINVAL

The value of base is not supported.

ERANGE

The value to be returned would have caused overflow.

AUTHOR

These interfaces were developed by OSF and HP.

STANDARDS CONFORMANCE

wcstol(): XPG4

wcstoul(): XPG4

wcstoll(): C99

wcstoull(): C99

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.