I am not sure how can I find the encoding of the file. I am trying to upload the CSV file only with utf-8 and find if there are any non utf-8 characters I want to show an error message.
I am using Papa persor for parsing.
How can I read the encoding of the file either in java or in js.
var fileElement = element.find('.csv-upload');
var file = fileElement[0].files[0]
var parseConfig = {
skipEmptyLines: true,
header: true,
encoding:'UTF-8',
trimHeaders: true,
complete: function (content) {
scope.onFileRead(content, fileElement[0]);
}
};
if (scope.rowsToParse) {
parseConfig.preview = scope.rowsToParse;
}
if (file) {
Papa.parse(file, parseConfig);
}