Thread overview
[Issue 10001] string formatting with underscores
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=10001

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #1 from hsteoh@quickfur.ath.cx ---
How would std.format know how many digits each to insert an underscore? In English notation, we generally group digits in 3's, but in other locales, other groupings are used (e.g., grouping digits by 4's).

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=10001

--- Comment #2 from bearophile_hugs@eml.cc ---
(In reply to hsteoh from comment #1)
> How would std.format know how many digits each to insert an underscore? In English notation, we generally group digits in 3's, but in other locales, other groupings are used (e.g., grouping digits by 4's).

One possible solution is to also ask for the group size in the formatting string:

format("%3_d", 1000000) => 1_000_000
format("%4_x", 0xa5b71a) => 0xa5_b71a


Another solution is to keep this functionality out of format/write and add a function (perhaps a callable struct with a toString method that accepts a delegate) to Phobos that does just the grouping:

format("%s", withSeparators(1000000, 3, '_')) => 1_000_000

Where 3 and '_' are the defaults for the second and third argument.

--
March 23, 2017
https://issues.dlang.org/show_bug.cgi?id=10001

hsteoh@quickfur.ath.cx changed:

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

--- Comment #3 from hsteoh@quickfur.ath.cx ---
Robert Schadek has submitted a pull for this:

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

--
April 19, 2017
https://issues.dlang.org/show_bug.cgi?id=10001

--- Comment #4 from github-bugzilla@puremagic.com ---
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/5de9af20ad07ebe485394309867073baa53b627b Merge pull request #5303 from burner/origin/formatunderscore

fix Issue 10001 - std.format insert underscores into numbers merged-on-behalf-of: unknown

--
April 19, 2017
https://issues.dlang.org/show_bug.cgi?id=10001

github-bugzilla@puremagic.com changed:

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

--
June 17, 2017
https://issues.dlang.org/show_bug.cgi?id=10001

--- Comment #5 from github-bugzilla@puremagic.com ---
Commit pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/5de9af20ad07ebe485394309867073baa53b627b Merge pull request #5303 from burner/origin/formatunderscore

--
January 05, 2018
https://issues.dlang.org/show_bug.cgi?id=10001

--- Comment #6 from github-bugzilla@puremagic.com ---
Commit pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/5de9af20ad07ebe485394309867073baa53b627b Merge pull request #5303 from burner/origin/formatunderscore

--