On Tuesday, 25 May 2021 at 23:41:39 UTC, Paul Backus wrote:
From [the documentation of `formattedWrite`][1]:
Separator
Inserts the separator symbols ',' every X digits, from
right to left, into numeric values to increase readability.
The fractional part of floating point values inserts the
separator from left to right. Entering an integer after the
',' allows to specify X. If a '*' is placed after the ',' then
X is specified by an additional parameter to the format
function. Adding a '?' after the ',' or X specifier allows to
specify the separator character as an additional parameter.
So the syntax you want is:
writeln(format("%,?d", '`', intAmount));
Thanks for your reply, but no, let me clarify:
I do not want 123\`456\`789 or whatever else custom delimiter.
I just want to output what is already set in the LC_ALL locale
environment variable which in my case results in 123,456,789
which of course I can mimic hard-coding it, but the idea is ...
quite the opposite.
The ` (backtick) I used in my example was from another example I
found somewhere on the net saying that, when you use the backtick
character after issuing a setlocale() call, you'll get the output
accordingly to the LC_ALL variable. Needless to say I am not sure
whether this is correct or not because the documentation I came
across is confusing to say the least; furthermore, someone saying
not every implementation is compatible with this behavior and
someone else claiming it works for POSIX or the reverse I do not
remember correctly right now.
I do not need to use std.format.format().
I can welcome any other function in the standard library to
achieve this.