I am having some issues while trying to parse some date from a .csv file using javascript. The issue is simply that some characters appear strangely, as they are country specific and only used in Scandinavia. I have seen several people answer how to fix encoding when creating a .csv with javascript, but I can't make it work when extracting data. This is some of what I have tried:
var fileInput = document.getElementById('fileInput');
var reader = new FileReader();
reader.onload = function () {
var data = reader.result;
var BOM = "\uFEFF";
var csvContent = BOM + csvContent;
}
};
reader.readAsBinaryString(fileInput.files[0]);
-
if the problem is the data then you should include a sample of the data. without some data, the only thing anyone can do is guess.I wrestled a bear once.– I wrestled a bear once.2018年02月20日 23:40:56 +00:00Commented Feb 20, 2018 at 23:40
1 Answer 1
Have you tried using reader.readAsText()?
It should correctly handle utf-8 characters which seems to be your issue.
Sign up to request clarification or add additional context in comments.
Comments
default