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

--- Comment #2 from bearophile_h...@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.

--

Reply via email to