4

In locales, e.g. French, with comma as decimal indicator (where "5,2" means five and two-tenths), how do users separate function arguments from each other?

For example, in many programming/scripting languages, I could specify MAX(1.5, X) in an EN-US locale. How do you avoid the ambiguity between the comma as decimal indicator, and as argument separator?

In particular, I'm interested in how software that's perceived as user-friendly in the foreign locale does it. Obviously, it's a no-brainer to say, "though shalt use decimal POINTs", but that's not particularly "friendly".

Chris Pousset
  • 326
  • 1
  • 3
  • 8

1 Answers1

2

We struck this exact problem when putting together queries for our product using DB2.

We had a query along the lines of:

select fn (COLUMN_NAME,5.2) from TABLE_NAME

and the 5.2 was actually inserted dynamically by our software, based on a user selection (forget about injection attacks for now, they were prevented via another means).

In locales where "five and two tenths" was written as 5,2 (darn those Europeans), we ended up with:

select fn (COLUMN_NAME,5,2) from TABLE_NAME

which DB2 complained about bitterly.

The IBM-given solution was to ensure that separator commas had spaces on either side and decimal commas did not:

select fn (COLUMN_NAME , 5,2) from TABLE_NAME

But you'll find that many languages solve this problem in exactly the non-friendly way you mention.

None of the ISO C-like standards (well, none that I know of, anyway) allow a constant number to be declared as 5,2, despite the fact that ISO is very much an "internationalised" organisation.

They also don't require that keywords like if, while and for be localised into Arabic, or Mongolian, or Klingon, which would lead to code such as:

chugh (rIn)
    nobHa';
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • I feel like if I follow this answer, my existing code probably already behaves like that. e.g. if someone entered "hypot(1,2 , 3,4)" the way the parser works would already separate the tokens at the comma. So I'm assuming SQL works this way for the same reason. I was wondering whether users in European countries which use the comma would actually be happy with that, or whether they use a different separator. For instance, in the case of CSV files, I have heard that some countries use semicolons for cell separators. – Hakanai Apr 05 '22 at 05:07
  • @Hakanai, that depends entirely on what's doing the parsing. For example, ISO C would see this a a `hypot` function taking four arguments, regardless of your locale. DB2 sees it as two arguments (1.2 and 3.4) or four arguments (1, 2, 3, and 4) depending on locale. – paxdiablo Apr 05 '22 at 05:24
  • Yeah, I realise this, but I wonder whether that actually equates to the users in those regions thinking it perfectly reasonable to have to input it like that. – Hakanai Apr 06 '22 at 10:07