www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23282] New: locale decimal separator unsued [dot vs comma]

https://issues.dlang.org/show_bug.cgi?id=23282

          Issue ID: 23282
           Summary: locale decimal separator unsued [dot vs comma]
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

The slightly modified code from issue 18018 

```fmt.d
import std.stdio;
import core.stdc.locale;
import std.string;

void main ()
{
   auto p = setlocale(LC_NUMERIC, "");
   writeln (p);
   writeln(p ? fromStringz(p) : "FAILURE");
   auto lc = localeconv();
   writefln("Decimal separator: '%s'", *lc.decimal_point);
   writefln("Thousand separator: '%s'", *lc.thousands_sep);
   writefln("%f", 1234567.1234);
}
```

does not use the comma as decimal separator. 

$ dmd fmt
$ LANG=de_DE.utf8 ./fmt 
7401B0
de_DE.utf8
Decimal separator: ','
Thousand separator: '.'
1234567.123400

expected:
1234567,123400
or even
1.234.567,123400

I wonder if there is any way in current D how to reliably achive this*). The
documentation [1] does not know decimal separators. It only mentions the word
"separator" in the context of grouping. The fracional digits are always
separated by a "dot". If the documentation defines the D formatting, must the
output

   1234567,123400

given in issue 18018 considered a bug?

*) Without search/replacing . by , in the output.

[1] std.format
    https://dlang.org/phobos/std_format.html

--
Aug 04 2022