[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setlocale ?
From: |
CdeMills |
Subject: |
Re: setlocale ? |
Date: |
Thu, 6 Oct 2011 06:41:30 -0700 (PDT) |
John W. Eaton wrote:
>
> When I wrote that, I was thinking of things like textread and the
> Octave parser itself. It looks like textread may ultimately use C++
> library functions to read numbers, so locale settings may help. But
> the parser does not recognize numbers that way, so it would not
> automatically follow locale conventions just by calling setlocale.
>
Hello,
C++ locales are different beast from C locales. The key is to call member
function imbue() on streams. To keep thing safe, I have added the ability
for fscanf and sscanf ONLY to use their third argument as a locale
indicator. The function imbue() is appropriately called on the stream passed
as arguement only.
To this end, I modified oct-stream.h and file-io.cc. The patch has been
submitted on Savanah, item #34495. With it, I get
octave:3>x=sscanf("3,1416", "%f", "fr_BE")
x = 3.1416
Note that the decimal separator has been correctly interpreted. A "make
check" resulted in a single failure in svds.m
This is totally compatible with old scripts, as "C" is the locales "classic"
style name.
Todo: implement the same for scanf. Unfortunatelly, it's a wrapper for
Ffscanf, and I didn't find the implementation inside the sources.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/setlocale-tp3875161p3878295.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
Re: setlocale ?, Søren Hauberg, 2011/10/05