http://qs321.pair.com?node_id=11119941


in reply to A locale independent sprintf?

After your post I quickly checked and was relieved to find that C's sprintf has not yet been touched by the locale police. phewww. Although I found this:

For some numeric conversions a radix character ("decimal point") or thousands' grouping character is used. The actual character used depends on the LC_NUMERIC part of the locale. (See setlocale(3).) The POSIX locale uses '.' as radix character, and does not have a grouping character.

And also this, which distinguishes between %g and %'g

' For decimal conversion (i, d, u, f, F, g, G) the output is to be grouped with thousands' grouping characters if the locale infor‐ mation indicates any.

Perhaps issue a feature request that Perl follows the same principle. You will do mankind a favour. Unless it does already?

bw, bliako

Replies are listed 'Best First'.
Re^2: A locale independent sprintf?
by swl (Parson) on Jul 29, 2020 at 07:12 UTC

    Looking at the docs for sprintf, perl uses its own implementation of sprintf. There is no mention in it of thousands separators, so I think we're OK on that front.