Reputation: 11
Website needs to serve CSV files encoded as windows-1252 to users on Windows workstations, and encoded as UTF-8 to everyone else. I can do this with two URL links, but then the user has to figure out on his own which one to click.
Users don't typically know or care which character encoding their workstation is using. I would rather use JavaScript to automatically determine which URL to request.
How to I determine the user's native character encoding?
I would rather determine the encoding rather than Windows or not, to future-proof the application for when Windows switches to UTF-8.
Upvotes: 0
Views: 63
Reputation: 11
Thank you Christopher, the BOM is the way to go. Converting to UTF-8 and including the BOM creates an universal CSV file that can be opened in Windows and non-Windows devices.
This line of code in Classic ASP VBScript writes the UTF-8 BOM, which needs to be the very first three characters of the file. The BOM will not be visible when the file is opened.
Response.Write Chr(239) & Chr(187) & Chr(191)
Upvotes: 1