When I receive a CSV file as a response from an API, I encounter issues with special characters in French appearing distorted. The content in the CSV files looks like this:
Exampleé of Weiéérdnesséé
Is there a way to standardize these characters to ANSI Latin I? My endpoints are set up using Express where I make a call to the database and use csv-express
to format the response as CSV.
router.get('/', async (req, res) => {
const result = await MyDbSession.query(`
SELECT * FROM my_table;
`)
res.csv(result)
})
Edit: I attempted to set res.charset
and
res.set('content-type', 'text/csv; charset=iso-8859-1')
, but it did not resolve the issue. Here is what was tried:
...
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)
})