1

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)
})
theJuls
  • 6,788
  • 14
  • 73
  • 160

1 Answers1

0

If you have access to the database implementation you could try to update the charset which is currently used to UTF-8 to standardize your responses.

Léo Stephan
  • 1
  • 1
  • 3