开发者

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 an EN-US locale. How do you avoid the ambiguity between the comma as decimal indicator, and as argument separator?

In particular, I'm in开发者_如何学JAVAterested 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".


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';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜