This example shows how to convert a Unicode string to a long integer.

#include <stdio.h>
#include <unidef.h>

int main(void) {

LocaleObject  locale_object;

UniChar       uni_string[] = L"110134932";
UniChar       *uni_stop_string;
long 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 = UniStrtol(locale_object, uni_string, &uni_stop_string,
                        10, &long_num);

         if (rc != ULS_SUCCESS) {
           printf("UniStrtol error: return code = %u\n", rc);
           return 1;
         }

         else {
           printf("The long integer is %ld\n", long_num);
           return (ULS_SUCCESS);
         }


}


[Back: UniStrtol - Related Functions]
[Next: UniStrtol - Topics]