This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

locale "de_DE.UTF-8", fscanf problem?


Hello,

There seems to be an "unbalance" with fprintf and fscanf when using the "de_DE.UTF-8" locale.

The following program correctly writes "2,5" (decimal comma) to a file. But reading with fscanf fails - the decimal comma is treated as "end of number".

Regards,
Tilman

--------------

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   double test;
   setlocale(LC_NUMERIC, "de_DE.UTF-8");

   FILE* fp = fopen("test.txt", "w");
   fprintf(fp, "%f", 2.5);
   fclose(fp);

   printf("fprintf writes:\n");
   system("cat test.txt");

   fp = fopen("test.txt", "r");
   fscanf(fp, "%lf", &test);
   fclose(fp);

   printf("\nfscanf reads:\n%f\n", test);
   return 0;
}




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]