Alex Rivera | Logout

With a browser, how do I know which decimal separator the operating system uses?

Asked 2009-07-02T14:19:45.283
103

I'm developing a Web application.

I need to display some decimal data correctly so that it can be copied and pasted into a certain GUI application that is not under my control.

The GUI application is locale-sensitive and it accepts only the correct decimal separator that is set in the system.

I can guess the decimal separator from Accept-Language and the guess will be correct in 95% cases, but sometimes it fails.

Is there any way to do it on server side (preferably, so that I can collect statistics), or on client side?

Update:

The whole point of the task is doing it automatically.

In fact, this Web application is a kind of online interface to a legacy GUI that helps to fill the forms correctly.

The kind of users that use it mostly have no idea on what a decimal separator is.

The Accept-Language solution is implemented and works, but I'd like to improve it.

Update2:

I need to retrive a very specific setting: decimal separator set in Control Panel / Regional and Language Options / Regional Options / Customize.

I deal with four kinds of operating systems:

  1. Russian Windows with a comma as a DS (80%).
  2. English Windows with a point as a DS (15%).
  3. Russian Windows with a point as a DS to make poorly written English applications work (4%).
  4. English Windows with a comma as a DS to make poorly written Russian applications work (1%).

All clients are in Russia and the legacy application deals with Russian goverment-issued forms, so asking for a country will yield 100% of Russian Federation, and GeoIP will yield 80% of Russian Federation and 20% of other (incorrect) answers.

Edit
Report

1 Answer

2

Even if you knew what locale this "GUI Application" is running under, you still have to figure out how it is getting the current locale, and how it is determining the decimal separator.

I don't know how it is done on a Mac, but Windows applications are supposed to interrogte the user's preferences set via the Control Panel. It's quite possible this mystery applicaiton is ignoring those settings, and using their own internal setup instead.

Or perhaps they're taking the current locale, and inferring the rest, rather than being told.

Even then, in English, numbers are given in groups of three digits, with a comma separating the groups, i.e.:

5,197,359,078

Unless the number was an integer that contains a phone number:

519-735-9078

Unless of course the number was an integer that contains an account number:

5197359078

In which case, you're back to hard-coded overridden logic.

Edit: Removed currency example, since currency has its own formatting rules.

answered 2009-07-04T20:26:57.867

Your Answer