Open philipp-kempgen opened 6 months ago
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.
Discussion
Number#humanize
andInt#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 spaceReferences:
https://en.wikipedia.org/w/index.php?title=Space_(punctuation)&oldid=1211874527#Unit_symbols_and_numbers
https://en.wikipedia.org/w/index.php?title=ISO_31-0&oldid=1193092792#Expressions