From 98261ec44f742c4aa50af2a47df7c69e7ea5dafb Mon Sep 17 00:00:00 2001 From: Jussi Laasonen Date: Mon, 11 Mar 2019 13:35:29 +0100 Subject: [PATCH] Load CSVs as latin1 --- lib/extractFromDir.js | 3 ++- lib/extractFromDir.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/extractFromDir.js b/lib/extractFromDir.js index 87a1eb7..d1cfc80 100644 --- a/lib/extractFromDir.js +++ b/lib/extractFromDir.js @@ -6,7 +6,8 @@ const mapNames = require('./mapNames') const Reference = require('./Reference') function extractFromFile (fileName) { - const contents = fs.readFileSync(fileName) + const encoding = 'latin1' + const contents = fs.readFileSync(fileName, { encoding }) return extractDocuments(contents) } diff --git a/lib/extractFromDir.test.js b/lib/extractFromDir.test.js index 7e61229..6bdce42 100644 --- a/lib/extractFromDir.test.js +++ b/lib/extractFromDir.test.js @@ -50,5 +50,5 @@ test('Counts hits from all the files in the folder', () => { }) test('Loads correct files', () => { - expect(fs.readFileSync.mock.calls).toEqual(_.keys(files).map(file => [`${directory}/${file}`])) + expect(fs.readFileSync.mock.calls).toEqual(_.keys(files).map(file => [`${directory}/${file}`, { encoding: 'latin1' }])) })