Want to simlpy read user-input files as text.
Can rely on modern browser usage, so I use FileReader for that (which works like a charm).
reader.readAsText(myfile, encoding);
I know that encoding
defaults to UTF-8.
But as my users will upload files from various sources (Windows, Mac, Linux) and various browsers I ask the user to provide the encoding via a select box.
So e.g. for a western european windows text file I expect the user to choose e.g. windows-1252.
I was not able to find a list of supported encodings for FileReader (assuming this is at least depending on the browser).
I am not asking to auto-determine the encoding, I just want to fill my select box in a way like:
<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 do I get a list of supported encodings to fill the option values?
- How to determine the exact writing of those values (is it 'utf8' or 'UTF-8' or...) and are those depending on the OS / browser?
- Does readAsText(myfile, unsupportedEncoding) throw any error which I can catch if encoding is not supported?
I'd prefer not to use any major 3rd party libraries for that.
Bonus Question:
Is there a simple way to get meaningful translations of the values, e.g. cp10029 means Mac (Central European)?