How do I get UTF-8 support on my API? At the moment, a string outputs like this:
name: \"John D�m\"
Instead of:
name: \"Joh
Hook into you response generator or create a middleware that does the following:
res.header("Content-Type", "application/json; charset=utf-8");
Otherwise the browser displays the content in his favorite encoding.
If this doesn't help you DB is probably in the wrong encoding.
Edit: Since the answer is nearly 5 years old, the API has changed. For current node.js versions use:
res.setHeader("Content-Type", "application/json; charset=utf-8");
I can't solve this problem with setting content type. I solved this problem with encode function.
res.cookie('someCookie', someCookie, {
encode: c => c,
});
For more information: express cookie
ExpressJS version: 4.16.4
My problem solved with this:
res.writeHeader(200 , {"Content-Type" : "text/html; charset=utf-8"});