Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a JavaScript solution that I just wrote based on the method shown <a href="http://www.codeproject.com/Articles/80083/Detecting-User-Regional-Settings-In-The-Web-Browse.aspx" rel="noreferrer">here</a>:</p> <pre><code>function getListSeparator() { var list = ['a', 'b'], str; if (list.toLocaleString) { str = list.toLocaleString(); if (str.indexOf(';') &gt; 0 &amp;&amp; str.indexOf(',') == -1) { return ';'; } } return ','; } </code></pre> <p>The key is in the toLocaleString() method that uses the system list separator.</p> <p>You could use JavaScript to get the list separator and set it in a cookie which you could then detect from your server.</p> <p>I checked all the Windows Locales, and it seems that the default list separator is virtually always either ',' or ';'. For some locales the drop-down list in the Control Panel offers both options; for others it offers just ','. One locale, Divehi, has a strange character that I've not seen before as the list separator, and, for any locale, it is possible for the user to enter any string they want as the list separator.</p> <p>Putting random strings as the separator in a CSV file sounds like trouble to me, so my function above will only return either a ';' or a '.', and it will only return a ';' if it can't find a ',' in the Array.toLocaleString string. I'm not entirely sure about whether array.toLocaleString has a format that's guaranteed across browsers, hence the indexOf checks rather than picking out a character at a specific index.</p> <p>Using Array.toLocaleString to get the list separator works on IE6, IE7, and IE8, but unfortunately it doesn't seem to work on Firefox, Safari, Opera, and Chrome (or at least the versions of those browsers on my computer): they all seem to separate array items with a comma, irrespective of the Windows "list separator" setting.</p> <p>Also worth noting that by default Excel seems to use the system "decimal separator" when it's parsing numbers out of CSV files. Yuk. So, if you're localizing the list separator you might want to localize the decimal separator too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload