0

I use express and jade to render html templates. To support translation and locales, i use an object for each locale, as i use french characters, there are many of special characters lice ç, é , è, à , but the html result replace all by �.

How to deal with utf-8 encoding ?

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • UTF-8 is the default character encoding for Node and Jade, so I wonder if your input data is actually valid UTF-8 to begin with. Can you show some code? – robertklep May 11 '16 at 10:00
  • Thankyou @robertklep, i think that the fs.readFile is the problem, `fs.readFile(pathToFile, 'utf-8', function (err, string) { // the string here is mal formatted \n res.send(string); })` – Houssem Fathallah May 11 '16 at 10:14
  • The problem is on file encoding and the need for additional workaround http://stackoverflow.com/questions/24356713/node-js-readfile-error-with-utf8-encoded-file-on-windows – Houssem Fathallah May 11 '16 at 10:45
  • If a BOM is your issue, you could use [`strip-bom`](https://www.npmjs.com/package/strip-bom) on `string`. – robertklep May 11 '16 at 10:49

0 Answers0