You just want to read the input / output files as text.
May rely on the use of modern browsers, so I use FileReader for this (which works like a charm).
reader.readAsText(myfile, encoding);
I know that encodingthe default is UTF-8.
But since my users will download files from different sources (Windows, Mac, Linux) and various browsers, I ask the user to provide the encoding through the selection box.
So, for example, for a Windows text file in the Western European format, I expect the user to select, for example. windows-1252.
I was unable to find a list of supported encodings for FileReader (assuming this at least depends on the browser).
I do not ask for automatic encoding detection, I just want to fill in the selection box as follows:
<select id="encoding">
<option value="windows-1252">Windows (Western Latin)</option>
<option value="utf-8">UTF-8</option>
<option value="...">...</option>
</select>
So my questions are:
- Where can I get a list of supported encodings to populate parameter values?
- How to determine the exact record of these values (is it "utf8" or "UTF-8" or ...) and depend on the OS / browser?
- Does readAsText (myfile, unsupportedEncoding) produce any error that I can catch if the encoding is not supported?
I would prefer not to use any large third-party libraries for this.
Bonus question:
Is there an easy way to get meaningful translations of values, for example. Does cp10029 mean Mac (Central European)?
source
share