Search code examples
javascriptcsvencodingpapaparse

JavaScript hebrew CSV parsing issue


so i got a csv file saves as CSV -UTF-8 file from excel on the right its in visual studio on the left its in excel.

when im trying to parse with PapaParse/csv-parser, i still see the output in <?> format which it means encoding : PapaParse try:

 papa.parse(file, {
    worker: true, 
    step: function (result) {
       count++; 
       console.log(result.data[0])
    },
    complete: function (results, file) {//
       console.log('parsing complete read', count, 'records.');
    }
});

csv-reader try:

const csv = require('csv-parser');
const results = [];
fs.createReadStream('Cities.csv')
   .pipe(csv())
   .on('data', function (datarow) {
       results.push(datarow);
   })
   .on('end', function () {
       console.log(results.toString('utf-8");
   });

In both situations the output is in <?> cant read hebrew chars


Solution

  • The problem was not because of the code, but because of the console properties. I had to change the font so that the console can display the Hebrew letters correctly.