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 which 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 webapp is a kind of online interface to a legacy GUI which 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:
All 100% of 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.
Click File > Options. On the Advanced tab, under Editing options, clear the Use system separators check box. Type new separators in the Decimal separator and Thousands separator boxes.
Great Britain and the United States are two of the few places in the world that use a period to indicate the decimal place. Many other countries use a comma instead. The decimal separator is also called the radix character.
Here is a simple JavaScript function that will return this information. Tested in Firefox, IE6, and IE7. I had to close and restart my browser in between every change to the setting under Control Panel / Regional and Language Options / Regional Options / Customize. However, it picked up not only the comma and period, but also oddball custom things, like the letter "a".
function whatDecimalSeparator() { var n = 1.1; n = n.toLocaleString().substring(1, 2); return n; }
function whatDecimalSeparator() { var n = 1.1; n = n.toLocaleString().substring(1, 2); return n; } console.log('You use "' + whatDecimalSeparator() + '" as Decimal seprator');
Does this help?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With