delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/12/17/04:36:49

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=Ry2
l6X+l0eE3cmANZKBAhjFa0j90u9DFic4iy0Myfp3T3k0GzvOog4kl/wQWqoBqYPO
nMz6hhBkgoooPWz8AGGjQFSFZp67c4mAh1raJ/V35A5RFIvH54zthseRJCf2vP65
uR6bcdrUCKgbFI79jtIuWJGnsLdgIHOi5+9IyNYI=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; s=default; bh=jshHSChOz
YIevb30ED8WcPSWMeQ=; b=JaFYK0dYJZsGejZyy/xWM88Q5ZNDkAFmAhs0MDiXd
Xzi3vp4PtnWrNwQ3CvAlYQH9qgJ7R+Rvsw9dnG3pTeZng7UoX1y7t0glHsy0Xt4T
QkbdOuxC+n1rEvgxiWyj1+m47rk1oufRRu6rNijgUZumo/C4FWSLEd2b+oAsLjN+
o8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=BAYES_40,LIKELY_SPAM_SUBJECT,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2
X-HELO: plane.gmane.org
To: cygwin AT cygwin DOT com
From: "Tilman Kuepper" <tilman DOT kuepper AT hm DOT edu>
Subject: locale "de_DE.UTF-8", fscanf problem?
Date: Tue, 17 Dec 2013 10:09:43 +0100
Lines: 38
Message-ID: <l8p4cd$gio$1@ger.gmane.org>
Mime-Version: 1.0
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019