4 ms·
Consider only this: "1.001" I'll use JavaScript numeric literals here as my translation medium (ironic!): Norway locale parses it to: 1001 USA locale parses
by juliusmusseau 7y ago
Consider only this: "1.001"
I'll use JavaScript numeric literals here as my translation medium (ironic!):
Norway locale parses it to: 1001
USA locale parses it to: 1.001
France locale parses it to: NaN
https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/ind...
- mort96 7y agoNo. In a programming context, any norwegian or french programmer would expect that to evaluate to 1.001, not 1001 or NaN.
- eitland 7y agoSweet summer child, isn't that what people say these days? I and you can agree that the reasonable thing to do is to accept American encoding. (The below is somewhat simplified, the way I remember it on a late Saturday night 10+ years later.) The outsourced team of programmers from our software vendor did not. They (mostly) used the built in regional settings in Windows (best practice, don't reinvent the wheel) meaning we had to come up with ways to make sure the machines ran with wrong regional settings (since a lot of stuff was already serialized that way && critical parts of the software was hardcoded to use US standard.) Fun times ;-)
- userbinator 7y agoI remember Excel also has(had?) some very disturbing behaviour around the interaction of CSV files and the regional decimal point separator settings.
- kozziollek 7y agoNot sure about CSV files, but every time I'm pasting numbers generated by Python or Java I had to use Notepad or Excel itself to replace dots to commas because of (Windows'!) regional settings.
- deleted 7y ago[deleted]
- HelloNurse 7y agoIn a somebody sent this input to my program context, designing some means to choose between these three results (or possibly others) is the main concern. Actual parsing is the easy part.
- juliusmusseau 7y agoDo you get the user to choose? Great, now the UI is 2x more complex. Do you just go with what the browser or client locale says? (User lives in Canada but their laptop is set to Turkish locale). Go with the locale tied to the geo location of the user instead? (User above stubbornly enters all amounts using Norwegian conventions after completing high school in Norway). If it's important, a confirmation page presented to the user and formatted in their presumed locale can help a lot.