0

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. Commented Feb 20, 2018 at 23:40

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.