Support thousands separator

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start with include/boost/format/parsing.hpp at lines 172–173 and the documentation passage describing the printf option. Investigate how locale and imbue would interact with Boost::format, including the reported Boost.Multiprecision behavior. Done means defining and implementing thousands separators consistently, with coverage for the affected formatting cases.

Written by the indexing model from the issue text.

Description

I know the docs say

the ' printf option (format with thousands grouping characters)) has no effect in format.

and the code says
https://github.com/boostorg/format/blob/c1170a6d546b36f9399f3983fad0994e8f946d8f/include/boost/format/parsing.hpp#L172-L173

but it would be really neat if this could be supported in the future.

I assume the issue is that Boost::format is essentially trying to achieve all (or at least the majority) of its formatting using standard stream flags and there is none for thousands separators?

From https://stackoverflow.com/questions/17530408/print-integer-with-thousands-and-millions-separator it seems that what would be necessary is to use a imbue in combination with a locale.
Has this been considered yet?

EDIT: This approach seems to at least break when using Boost::multiprecision numbers with the stream at which case the thousands separator is ignored again.

Dominant language
C++
Stars
31
Forks
53
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/format

All issues in boostorg/format

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.