* locale "de_DE.UTF-8", fscanf problem?
@ 2013-12-17 9:35 Tilman Kuepper
2013-12-17 10:04 ` Corinna Vinschen
0 siblings, 1 reply; 5+ messages in thread
From: Tilman Kuepper @ 2013-12-17 9:35 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: locale "de_DE.UTF-8", fscanf problem?
2013-12-17 9:35 locale "de_DE.UTF-8", fscanf problem? Tilman Kuepper
@ 2013-12-17 10:04 ` Corinna Vinschen
2013-12-17 16:49 ` Corinna Vinschen
0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2013-12-17 10:04 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 712 bytes --]
On Dec 17 10:09, Tilman Kuepper wrote:
> 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
>
> --------------
> [...testcase...]
Weird. I was pretty sure that scanf is doing the right thing, but
apparently it doesn't. Thanks a lot for the testcase, I'll have a look
into this issue.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: locale "de_DE.UTF-8", fscanf problem?
2013-12-17 10:04 ` Corinna Vinschen
@ 2013-12-17 16:49 ` Corinna Vinschen
2013-12-18 20:53 ` Corinna Vinschen
0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2013-12-17 16:49 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]
On Dec 17 11:04, Corinna Vinschen wrote:
> On Dec 17 10:09, Tilman Kuepper wrote:
> > 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
> >
> > --------------
> > [...testcase...]
>
> Weird. I was pretty sure that scanf is doing the right thing, but
> apparently it doesn't. Thanks a lot for the testcase, I'll have a look
> into this issue.
A generic solution for this problem is much more complex than I
anticipated. I'll be looking into getting this into the next Cygwin
release, but it will take at least a couple of days to get this right,
so don't hold your breath for testing a fix within... uhm... the year
2013, I guess.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: locale "de_DE.UTF-8", fscanf problem?
2013-12-17 16:49 ` Corinna Vinschen
@ 2013-12-18 20:53 ` Corinna Vinschen
2014-01-01 21:03 ` Tilman Kuepper
0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2013-12-18 20:53 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
On Dec 17 17:49, Corinna Vinschen wrote:
> On Dec 17 11:04, Corinna Vinschen wrote:
> > On Dec 17 10:09, Tilman Kuepper wrote:
> > > 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
> > >
> > > --------------
> > > [...testcase...]
> >
> > Weird. I was pretty sure that scanf is doing the right thing, but
> > apparently it doesn't. Thanks a lot for the testcase, I'll have a look
> > into this issue.
>
> A generic solution for this problem is much more complex than I
> anticipated. I'll be looking into getting this into the next Cygwin
> release, but it will take at least a couple of days to get this right,
> so don't hold your breath for testing a fix within... uhm... the year
> 2013, I guess.
I applied a newlib patch today. Please give the next developer snapshot
from http://cygwin.com/snapshots/ a try.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: locale "de_DE.UTF-8", fscanf problem?
2013-12-18 20:53 ` Corinna Vinschen
@ 2014-01-01 21:03 ` Tilman Kuepper
0 siblings, 0 replies; 5+ messages in thread
From: Tilman Kuepper @ 2014-01-01 21:03 UTC (permalink / raw)
To: cygwin
> On Dec 17 17:49, Corinna Vinschen wrote:
> > On Dec 17 11:04, Corinna Vinschen wrote:
> > > On Dec 17 10:09, Tilman Kuepper wrote:
> > > > Hello,
> > > >
> > > > There seems to be an "unbalance" with fprintf and fscanf when using
> > > > the "de_DE.UTF-8" locale.
> > > >
> [...]
>
> I applied a newlib patch today. Please give the next developer snapshot
> from http://cygwin.com/snapshots/ a try.
>
> Thanks,
> Corinna
Yes, it works, good job! Thanks :-))
Happy New Year!
Tilman
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-01 21:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 9:35 locale "de_DE.UTF-8", fscanf problem? Tilman Kuepper
2013-12-17 10:04 ` Corinna Vinschen
2013-12-17 16:49 ` Corinna Vinschen
2013-12-18 20:53 ` Corinna Vinschen
2014-01-01 21:03 ` Tilman Kuepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).