Thursday, April 12, 2012

Separating arguments to a function, in locales with comma as decimal marker

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 a 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, "thou shalt use decimal POINTs", but that's not particularly "friendly".





1 comment:

  1. 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 :-)

    ReplyDelete