Thread overview
[Issue 20069] std.format digit grouping separator (aka thousands separator) needs to be revisited
Jul 22
shove
Jul 25
Dlang Bot
Aug 04
Dlang Bot
July 22
https://issues.dlang.org/show_bug.cgi?id=20069

shove <shove@163.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shove@163.com

--- Comment #1 from shove <shove@163.com> ---
(In reply to asumface from comment #0)
> Currently the default separator used by std.format is always ','.
> With the C locale (default) the number 123456.789 is thus formatted as
> "123,456.789,000".
> If another locale is activated, the output does not match the locale and
> sometimes even becomes a mess:
> writefln("%,f", 123456.789)
> de_DE.UTF-8: "1,234,56,,789,000"
> fr_FR.UTF-8: "1,234,56,,789,000"
> fr_CH.UTF-8: "123,456.789,000"
> en_IN.UTF-8: "123,456.789,000"
> nl_NL.UTF-8: "1,234,56,,789,000"
> hak_TW:      "123,456.789,000"
> ps_AF:       "12,345,6٫,789,000"
> unm_US:      "123,456.789,000"
> 
> The printf as defined by POSIX formats the same case as follows (I'd regard
> this as the generally correct formatting):
> printf("%'f", 123456.789)
> C: "123456.789000"
> de_DE.UTF-8: "123.456,789000"
> fr_FR.UTF-8: "123 456,789000"
> fr_CH.UTF-8: "123'456.789000"
> en_IN.UTF-8: "1,23,456.789000" (non-uniform group size!)
> nl_NL.UTF-8: "123456,789000"
> hak_TW:      "12,3456.789000"
> ps_AF:       "123٬456٫789000"
> unm_US:      "12 34 56.789000"
> 
> Grouping after the decimal separator should probably be made optional as it kind of is nonstandard behavior (scanf doesn't appear to handle such grouping, for example) yet useful for human interfacing nonetheless. Grouping should, unless overridden, behave according to the active locale, for the C locale, which is active by default, this means no grouping at all. This is useful because a formatted number such as 100000 is otherwise ambiguous for comma-decimal-users by default ("100,000").


In dealing with issue 20064, I also noticed the problems. I'll handle it together.

--
July 25
https://issues.dlang.org/show_bug.cgi?id=20069

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@shove70 updated dlang/phobos pull request #7112 "Fix issue 20064 - format separator fails with leading zeros" fixing this issue:

- Fix issue 20069 - std.format digit grouping separator (aka thousands separator) needs to be revisited

https://github.com/dlang/phobos/pull/7112

--
August 04
https://issues.dlang.org/show_bug.cgi?id=20069

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #7112 "Fix issue 20064,20069 - format functions make their final width and digits grouping conform to POSIX definition" was merged into master:

- 75f65a37fefd4547c3b25244d7d3ffb7ba4413cf by shove70:
  Fix issue 20069 - std.format digit grouping separator (aka thousands
separator) needs to be revisited

https://github.com/dlang/phobos/pull/7112

--