I have an API which gives me a CSV file as a response, however a lot of the content is in French and it has special characters are being screwed up. Stuff like this is appearing on the CSV files: Exampleé of Weiéérdnesséé
Is there a way to standardize the characters to be ANSI Latin I? My endpoints are implemented with express and I simply do a call to the database and use csv-express
to set the response as a csv type.
router.get('/', async (req, res) => {
const result = await MyDbSession.query(`
SELECT * FROM my_table;
`)
res.csv(result)
})
Edit: One thing I tried to do is set res.charset
and res.set('content-type', 'text/csv; charset=iso-8859-1')
, which do not seem to work. Basically the following was tried, but made no difference:
...
res.charset = 'Latin-1' // or 'iso-8859-1'
res.csv(result)
})
or
...
res.set('content-type', 'text/csv; charset=iso-8859-1')
res.csv(result)
})