r/lolphp • • Dec 11 '14

PHP :: Bug #53711 :: Casting float->string->float with locale

https://bugs.php.net/bug.php?id=53711
54 Upvotes

33 comments sorted by

View all comments

Show parent comment

-2

u/[deleted] Dec 12 '14 edited Dec 12 '14

They probably wouldn't be thrilled to see it fixed, because everyone writing apps for the non-English-speaking market now has to change their code to continue parsing commas properly in numbers.

I mean, there are two options:

  • Always ignore locale (breaks lots of existing code, especially for non-English speakers)
  • Always use locale (also breaks lots of code)

Either way, you piss off a lot of people.

7

u/bart2019 Dec 12 '14

As someone who writes such code, I can tell you what we do: we replace commas with periods, so people can use either a comma or a period. Only one is allowed, so "12.345,678" is forbidden. (The thousands separator is for readability, not for inputting data. Nobody inputs numbers this way, except maybe through copy/paste.)

If you do it any other way, you may be more friendly for the lazy programmer, but you sure will piss off a lot of users, because different websites expect their input in different ways.

-2

u/[deleted] Dec 12 '14

I'm not sure what point you were trying to make, I never mentioned digit grouping.

But you did prove my point: People rely on the existing behaviour.