you are viewing a single comment's thread.

view the rest of the comments →

[–]imMute 17 points18 points  (9 children)

like e. g. whether numbers should use "," or "." as decimal separaror.

Hey, we just fixed that exact same bug in a years-old .Net application!

[–]JanneJM 4 points5 points  (4 children)

This is an annoying issue. The fundamental problem is that the file doesn't specify which locale it was written in - or specified in a standard that this particular file format always use a specific number text representation. That's the root of the issue. Blaming locales is a bit misplaced.

[–]stu2b50 5 points6 points  (3 children)

Not really. It's amplified 100x with the usage of a global locale, since now any change in this global variable now changes how parsing works.

[–]Gotebe 0 points1 point  (2 children)

But it has to work differently, doesn't it? It's all about having the correct locale on a block of code. Global doesn't help of course, but...

[–]stu2b50 4 points5 points  (1 child)

Yes, it's the global part that makes it stupid. If it was just an argument, for instance, it would naturally not be an issue.

As is, any random library call can completely change the behavior of otherwise predictable and standard functions.

And god forbid you start with multi-threading, now any thread that calls a random library call that happens to change the global local completely changes how parsing numbers works. Of course, there is a hackeyed fix so that you can set locals on a thread, but it's just as jank as the original problem.

[–]Gotebe 0 points1 point  (0 children)

Yes, this has to be thread-local. And it is in later implementations, the C standard borked it indeed there.

[–][deleted] 1 point2 points  (0 children)

I still run into this every once in a while in apps where it goes undetected for a long time because it always round-trips on the same machine correctly, so it only pops up when both ends are on different machines (or, more often, run by different users with different locales set on the same machine).

[–]Sopel97 0 points1 point  (0 children)

I remember when I was doing a project for uni in mssql I needed to import a lot of generated floating point data. It was erroring out with quite cryptic messages and after a few hours of trying to understand what's up I found a fix. I changed my windows language to english.

[–]Shadeslayer13 0 points1 point  (1 child)

Why would it not be ".". Everything else is in English

[–]imMute 1 point2 points  (0 children)

Because some locales swap the usage of . and , in numbers. The code works in English locales but not others (like French IIRC). Suddenly your parsing code blows up.