Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

Guardian Native C Library Calls (t - z) wcstoul(3)
converted:
Character 0123456789ABCDEFGHIJ
abcdefghij
Value 012345678910111213141516171819
The subject string can optionally be preceded by a + (plus sign) or - (minus sign), but cannot
include an integer suffix (such as L). If the subject string is preceded by a - (minus sign), the con-
verted integer value has a negative value cast to unsigned integer. If the value of base is 16, the
characters 0x or 0X may optionally precede the sequence of letters or digits, following the sign,
if present.
The wide-character string is parsed to skip the initial whitespace characters, as determined by the
iswspace() function. Any nonspace character is the start of a potential subject string that may
form an unsigned long integer in the base specified by the base parameter. The subject sequence
is defined to be the longest initial substring that is of the expected form of unsigned long integer.
Any character that does not satisfy this expected form begins the final sequence of unrecognized
characters. The wcstoul() function sets the *endptr parameter to point to this final sequence of
unrecognized characters.
The LC_CTYPE category of the locale controls what wide characters are treated as spaces but
does not effect the interpretation of characters as part of the subject string. The characters in the
subject string are always treated as if the locale was the C locale.
EXAMPLES
The following example shows how to convert convert a wide-character string to an unsigned
long integer:
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <errno.h>
#define WLENGTH 40
main()
{
wchar_t WCString[WLENGTH], *endptr;
unsigned long int retval;
(void)setlocale(LC_ALL, "");
if (fgetws(WCString, WLENGTH, stdin) != NULL) {
errno = 0;
retval = wcstoul ( WCString, &endptr, 0 );
if (retval == 0 && (errno != 0
|| WCString == endptr)) {
/* No conversion could be performed */
printf("No conversion performed\n");
} else if (retval == ULONG_MAX && errno !=0){
/* Error handling */
} else {
/* retval contains unsigned long integer */
printf("Unsigned integer in decimal is %lx\n", retval);
}
}
}
527192-018 Hewlett-Packard Company 7173