Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number#humanize and Int#humanize_bytes should separate number and unit by a space #14349

Open
philipp-kempgen opened this issue Mar 7, 2024 · 1 comment · May be fixed by #15176
Open

Number#humanize and Int#humanize_bytes should separate number and unit by a space #14349

philipp-kempgen opened this issue Mar 7, 2024 · 1 comment · May be fixed by #15176
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. help wanted This issue is generally accepted and needs someone to pick it up status:discussion topic:stdlib:numeric

Comments

@philipp-kempgen
Copy link

Discussion

Number#humanize and Int#humanize_bytes should separate the numerical value and unit by a space, according to international standards.

The kind of space should be passed as an argument.

Examples of what you may want to pass as a space argument (non-exhaustive):

  • nil - nothing, for the current behavior
  • '\u0020' resp. ' ' – a plain space, might be the most compatible space character
  • '\u00A0' – a non-breaking space
  • '\u2009' – a thin space
  • '\u202F' – a thin non-breaking space

References:

https://en.wikipedia.org/w/index.php?title=Space_(punctuation)&oldid=1211874527#Unit_symbols_and_numbers

The International System of Units (SI) prescribes inserting a space between a number and a unit of measurement […]

https://en.wikipedia.org/w/index.php?title=ISO_31-0&oldid=1193092792#Expressions

Numerical value and unit symbol are separated by a space. […]

@straight-shoota
Copy link
Member

straight-shoota commented Mar 8, 2024

Adding an option to configure a space between value and unit sounds like a good idea.

There are good practical reasons to skip the space in an environment where machine readability matters. Grepping formatted numbers is much easier if you don't have to account for (variations of) whitespace, for example.
So I'd prefer to leave the current behaviour as default. Also to avoid disruptions.

It might make sense to have a simple value like true to indicate having a space. With this option, callers won't have to worry about the details what specific kind of space to use and just say they want the default space. I think the default should be a non-breaking space to avoid inconsistencies around line breaks. Whether thin or normal could be up for debate.

@straight-shoota straight-shoota added good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. help wanted This issue is generally accepted and needs someone to pick it up labels Apr 13, 2024
@CTC97 CTC97 linked a pull request Nov 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. help wanted This issue is generally accepted and needs someone to pick it up status:discussion topic:stdlib:numeric
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants