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

wcstoimax(3) Guardian Native C Library Calls Reference Manual
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. 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 space characters (as determined by the
iswspace() function). Any nonspace character is the starting of a potential subject string that
may form an 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 intmax_t integer. Any character
that does not satisfy this expected form begins the final sequence of unrecognized characters.
The wcstoimax() function sets the *endptr parameter to point to this final sequence of unrecog-
nized 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 converts a wide-character string to a intmax_t integer.
#include <inttypes.h>
#include <wchar.h>
#include <locale.h>
#include <errno.h>
#define WLENGTH 40
main()
{
wchar_t WCString[WLENGTH], *endptr;
intmax_t retval;
(void)setlocale(LC_ALL, "");
if (fgetws(WCString, WLENGTH, stdin) != NULL) {
errno = 0;
retval = wcstoimax ( WCString, &endptr, 0 );
if (retval == 0 && (errno != 0
|| WCString == endptr)) {
/* No conversion could be performed */
printf("No conversion performed\n");
} else if (errno != 0 && (retval == LONG_MAX
|| retval == LONG_MIN)) {
/* Error handling */
} else {
/* retval contains intmax_t integer */
printf("Integer in decimal is %d\n", retval);
}
}
}
7160 Hewlett-Packard Company 527192-018