[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
strtod bug with locales using non-ASCII decimal separators
From: |
Roozbeh Pournader |
Subject: |
strtod bug with locales using non-ASCII decimal separators |
Date: |
Wed, 19 Mar 2003 23:36:47 +0330 (IRT) |
glibc's current 'strtod' can't parse numbers *starting* with a decimal
separator if the locale is using a non-ASCII decimal separator. Test case
follows. Changing the string to "\x30\xd9\xab\x35" makes it working. So
does changing the string to ".5" and setting the locale to "C".
roozbeh
Test case:
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *s = "\xd9\xab\x35"; /* Unicode: U+066B (ARABIC DECIMAL SEPARATOR),
U+0035 (DIGIT FIVE) */
char *locale = "fa_IR.UTF-8";
char *endptr;
double ret;
setlocale(LC_ALL, locale);
ret = strtod(s, &endptr);
printf("ret == %f, endptr - s == %d\n", ret, endptr - s);
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- strtod bug with locales using non-ASCII decimal separators,
Roozbeh Pournader <=