unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* locale-dependent number parsing?
@ 2010-04-05 16:56 Linas Vepstas
  2010-04-05 17:19 ` Mike Gran
  2010-04-05 19:26 ` Ludovic Courtès
  0 siblings, 2 replies; 4+ messages in thread
From: Linas Vepstas @ 2010-04-05 16:56 UTC (permalink / raw)
  To: Guile User

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

I've found the following bug/feature with guile-1.8.7 and would like to
solicit for comments.
Is this a guile bug? What's the proper work-around?

I've got a C program that does a setlocale (LC_ALL, "");   printf ("%f",
0.2000);

In the de_DE.utf8 locale, the result of the print is 0,2000  using a comma,
since
the comma is the "decimal separator" in most European locales. This numeric
string is then passed to scm_eval_string() which pukes on it, because it
does not
recognize 0,2  as a valid number.    This can be confirmed at the guile
command
line interpreter, which pukes on guile> (+ 0,2 0,2)  but works fine on (+
0.2 0.2)
even in the de_DE locale.

Is this really the expected behaviour? Is there a suggested work-around?

--linas

[-- Attachment #2: Type: text/html, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: locale-dependent number parsing?
  2010-04-05 16:56 locale-dependent number parsing? Linas Vepstas
@ 2010-04-05 17:19 ` Mike Gran
  2010-04-05 17:56   ` Linas Vepstas
  2010-04-05 19:26 ` Ludovic Courtès
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Gran @ 2010-04-05 17:19 UTC (permalink / raw)
  To: linasvepstas, Guile User

>From: Linas Vepstas <linasvepstas@gmail.com>
>
>I've found the following bug/feature with guile-1.8.7 and would like to solicit for comments.
>Is this a guile bug? What's the proper work-around?
>
>I've got a C program that does a setlocale (LC_ALL, "");   printf ("%f", 0.2000);
>
>In the de_DE.utf8 locale, the result of the print is 0,2000  using a comma, since 
>the comma is the "decimal separator" in most European locales. This numeric 
>string is then passed to scm_eval_string() which pukes on it, because it does not
>recognize 0,2  as a valid number.    This can be confirmed at the guile command 
>line interpreter, which pukes on guile> (+ 0,2 0,2)  but works fine on (+ 0.2 0.2) 
>even in the de_DE locale. 
>
>Is this really the expected behaviour? Is there a suggested work-around?

I know that for the pre-2.0 Guile, I tried to punt that problem upstream to 
libunistring, but, it is not likely to be implemented in libunistring.

http://savannah.gnu.org/support/?106998

But, I never got around to working on it, myself.

-Mike




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: locale-dependent number parsing?
  2010-04-05 17:19 ` Mike Gran
@ 2010-04-05 17:56   ` Linas Vepstas
  0 siblings, 0 replies; 4+ messages in thread
From: Linas Vepstas @ 2010-04-05 17:56 UTC (permalink / raw)
  To: Mike Gran; +Cc: Guile User

[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

On 5 April 2010 12:19, Mike Gran <spk121@yahoo.com> wrote:

> >From: Linas Vepstas <linasvepstas@gmail.com>
> >
> >I've found the following bug/feature with guile-1.8.7 and would like to
> solicit for comments.
> >Is this a guile bug? What's the proper work-around?
> >
> >I've got a C program that does a setlocale (LC_ALL, "");   printf ("%f",
> 0.2000);
> >
> >In the de_DE.utf8 locale, the result of the print is 0,2000  using a
> comma, since
> >the comma is the "decimal separator" in most European locales. This
> numeric
> >string is then passed to scm_eval_string() which pukes on it, because it
> does not
> >recognize 0,2  as a valid number.    This can be confirmed at the guile
> command
> >line interpreter, which pukes on guile> (+ 0,2 0,2)  but works fine on (+
> 0.2 0.2)
> >even in the de_DE locale.
> >
> >Is this really the expected behaviour? Is there a suggested work-around?
>
> I know that for the pre-2.0 Guile, I tried to punt that problem upstream to
> libunistring, but, it is not likely to be implemented in libunistring.
>
> http://savannah.gnu.org/support/?106998
>
> But, I never got around to working on it, myself.
>
>
Yeah, maybe I should say "never mind" at this point, since I now realize
that
my suggestion would make scheme source code  depend on locale, which
would break source code as it moves across national boundaries... Silly me.
Moral of the story: mixing printf with guile is a bad idea.

--linas

[-- Attachment #2: Type: text/html, Size: 2067 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: locale-dependent number parsing?
  2010-04-05 16:56 locale-dependent number parsing? Linas Vepstas
  2010-04-05 17:19 ` Mike Gran
@ 2010-04-05 19:26 ` Ludovic Courtès
  1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2010-04-05 19:26 UTC (permalink / raw)
  To: guile-user

Hi Linas,

In 1.9 there’s ‘locale-string->inexact’, which may be what you’re
looking for; see
<http://www.gnu.org/software/guile/docs/master/guile.html/Number-Input-and-Output.html>.

Thanks,
Ludo’.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-05 19:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-05 16:56 locale-dependent number parsing? Linas Vepstas
2010-04-05 17:19 ` Mike Gran
2010-04-05 17:56   ` Linas Vepstas
2010-04-05 19:26 ` Ludovic Courtès

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).