This example shows how to convert a Unicode string to an unsigned long integer.
#include <stdio.h>
#include <unidef.h>
int main(void) {
LocaleObject locale_object;
UniChar uni_string[] = L"110134932";
UniChar *uni_stop_string;
ULONG int long_num;
int rc;
/*****************************************************************/
/* Assumes LANG environment variable set to a valid locale name, */
/* such as fr_FR */
/*****************************************************************/
rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
(UniChar *)L"", &locale_object);
if (rc != ULS_SUCCESS) {
printf("UniCreateLocaleObject error: return code = %u\n", rc);
return 1;
}
rc = UniStrtoul(locale_object, uni_string, &uni_stop_string,
10, &long_num);
if (rc != ULS_SUCCESS) {
printf("UniStrtoul error: return code = %u\n", rc);
return 1;
}
else {
printf("The unsigned long integer is %lu\n", long_num);
return (ULS_SUCCESS);
}
}