This example shows how to convert a Unicode string to a double precision floating point number.
#include <stdio.h> #include <unidef.h> int main(void) { LocaleObject locale_object; UniChar uni_string[] = L"3.1415926This stopped it"; UniChar *uni_stop_string; double double_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 = UniStrtod(locale_object, uni_string, &uni_stop_string, &double_num); if (rc != ULS_SUCCESS) { printf("UniStrtod error: return code = %u\n", rc); return 1; } else { printf("The double precision number is %f\n", double_num); return (ULS_SUCCESS); } }