Add primitive check for file encoding when a file is uploaded and warn
if it's not UTF-8 Close #8
This commit is contained in:
@ -553,7 +553,8 @@ class CsvxmlPage {
|
||||
uploadFileForValidation(file) {
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.readAsText(file);
|
||||
let utf8 = true;
|
||||
reader.readAsText(file, utf8 ? 'UTF-8' : 'CP1251');
|
||||
|
||||
let app = this;
|
||||
|
||||
@ -563,6 +564,13 @@ class CsvxmlPage {
|
||||
|
||||
function handleValidation() {
|
||||
|
||||
(async function() {
|
||||
const result = reader.result;
|
||||
if (utf8 && result.includes('<27>')) {
|
||||
window.alert('The file encoding appears to not be UTF-8!\n\nTry exporting the file using the format "CSV (UTF-8)" if you use MS Excel or set the encoding to UTF-8 when exporting through LibreOffice!');
|
||||
}
|
||||
})();
|
||||
|
||||
// On loading success, check if the upload is valid JSON
|
||||
console.log("Read file");
|
||||
// Validate the file
|
||||
|
Reference in New Issue
Block a user