code:
var nerve = require("./nerve");
var sitemap = [
["/", function(req, res) {
res.respond("Русский");
}]
];
nerve.create(sitemap).listen(8100);
show in browser:
CAA:89
How it should be correct?
code:
var nerve = require("./nerve");
var sitemap = [
["/", function(req, res) {
res.respond("Русский");
}]
];
nerve.create(sitemap).listen(8100);
show in browser:
CAA:89
How it should be correct?
Nerve appears to interpret the strings you pass as binary strings, which results in the output you’re seeing. You can use the Buffer class to convert your UTF-8 chars to a binary string manually. You also need to set the charset in your headers:
var sitemap = [
["/", function (req, res) {
res.respond({
headers: {"Content-Type": "text/html; charset=utf-8"},
content: new Buffer("Русский", "utf8").toString("binary")
});
}]
];
If you want to try another framework, Express does a better job handling UTF-8. It interprets strings as UTF-8 and sets the charset correctly by default:
var app = require("express").createServer();
app.get("/", function (req, res) {
res.send("Русский");
});
app.listen(8100);