0
votes

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]);
1
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.

1 Answers

2
votes

Have you tried using reader.readAsText()?

It should correctly handle utf-8 characters which seems to be your issue.