is there a way to output formatted text following the locale settings ?
Paul Backus
snarwin at gmail.com
Tue May 25 23:41:39 UTC 2021
On Tuesday, 25 May 2021 at 22:37:25 UTC, someone wrote:
> writeln(format("%`d", intAmount)); /// please, note the
> backtick instead of ,
>
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));
[1]:
https://forum.dlang.org/post/vedxtnkolsmdlyfvmhsr@forum.dlang.org
More information about the Digitalmars-d-learn
mailing list