wcstod -- Convert Wide-Character String to Double

Format

#include <wchar.h>
double wcstod(const wchar_t *nptr, wchar_t **endptr);

Language Level: ANSI 93, XPG4
wcstod converts the wide-character string pointed to by nptr to a double value. The nptr parameter points to a sequence of characters that can be interpreted as a numerical value of type double. wcstod stops reading the string at the first character that it cannot recognize as part of a number. This character can be the wchar_t null character at the end of the string.

wcstod expects nptr to point to a string with the following form:

Note: The character used for the decimal point (shown as . in the above diagram) depends on the LC_NUMERIC category of the current locale.

In locales other than the "C" locale, additional implementation-defined subject sequence forms may be accepted.

The behavior of wcstod is affected by the LC_CTYPE category of the current locale.

Return Value
wcstod function returns the converted double value. If no conversion could be performed, wcstod returns 0. If the correct value is outside the range of representable values, wcstod returns +HUGE_VAL or -HUGE_VAL (according to the sign of the value), and sets errno to ERANGE. If the correct value would cause underflow, wcstod returns 0 and sets errno to ERANGE.

If the string nptr points to is empty or does not have the expected form, no conversion is performed, and the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

Example
This example uses wcstod to convert the string wcs to a floating-point value.

#include <stdio.h>
#include <wchar.h>
int main(void)
{
   wchar_t *wcs = L"3.1415926This stopped it";
   wchar_t *stopwcs;
   printf("wcs = \"%ls\"\n", wcs);
   printf("   wcstod = %f\n", wcstod(wcs, &stopwcs));
   printf("   Stop scanning at \"%ls\"\n", stopwcs);
   return 0;
   /**************************************************
      The output should be similar to:
      wcs = "3.1415926This stopped it"
         wcstod = 3.141593
         Stop scanning at "This stopped it"
   **************************************************/
}



strtod -- Convert Character String to Double
strtol -- Convert Character String to Long Integer
strtold -- Convert String to Long Double
strtoul -- Convert String Segment to Unsigned Integer
wcstol -- Convert Wide-Character to Long Integer
wcstoul -- Convert Wide-Character String to Unsigned Long
<wchar.h>