-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Adding support for environments that have a system locales with different decimal separator #20
Adding support for environments that have a system locales with different decimal separator #20
Conversation
…rent decimal separator
Hi, thanks for your PR. TBH I had no idea that float to string conversion was affected by the current locale (I personally try to stay away from using One thing that bothers me with your approach, is that you're changing the current behaviour to also parse strings using the current locale; while I agree that parsing a float, e.g. I'd rather change this line, when The problem is that apart from temporarily reverting setlocale() to |
Actually, this approach breaks a lot of tests: This is because strings that were using dots are not parsed correctly after a global |
…rent decimal separator - added normalizing for string after conversion to it from float value
@BenMorel, I added normalizing of string after conversion to it form float. Now I don't change regexp to valid format from locale configuration, just convert string to valid format. |
@manowark With the suggested changes it should be good to go! 👍 |
…rent decimal separator - fixed after code review
@BenMorel, done. |
Nice and clean. Thanks! |
@BenMorel, Thanks for the quick response and constructive comments. |
I'm going to release |
0.8.5 is released! |
STR:
.
(for examplede_DE.UTF-8
) or locale set by terminal variable likeexport LC_ALL=de_DE.UTF-8
For example:
It will not give an error if locale is equal to
eu_US
. But if locale is equal tode_DE
then there will be an errorBrick\Math\Exception\NumberFormatException : The given value "2,5" does not represent a valid number.
.It happened because in this environment PHP will use
,
as decimal separator and::of()
method must be sensitive to it.It can also happen when using Doctrine and convert float values from DB to brick/math type.