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

Support for other decimal separators #303

Open
emarj opened this issue Dec 5, 2022 · 0 comments
Open

Support for other decimal separators #303

emarj opened this issue Dec 5, 2022 · 0 comments

Comments

@emarj
Copy link

emarj commented Dec 5, 2022

This library currently supports only the dot . as a decimal separator. Unfortunately there is not a standard for this (see here for example). The comma , for example, is also heavily used.

It would be nice to have some support from the library in regard to this. This issue falls under the umbrella of localization, which is quite tedious to implement, but some global variables could be enough.

At the moment the dot is hard-coded here

if value[i] == '.' {

It would be really easy to support others decimal separators by introducing a global variable

var DecimalSeparator string = "."

that users can change from outside, and use it there. Of course the code for formatting the number should also be modified.

Sometimes one wants to support different formats. At this point would be possible to also allow for several separators. For example

var DecimalSeparators string = ".," //Support for both dot and comma

and

	if strings.Contains(DecimalSeparators, value[i]) {

For the formatting, the first separator DecimalSeparators[0] could be used.

What do you think? I would like to hear some opinion before (eventually) submitting a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant