There is a form to send a message.
<form action="/upload" method="post"> <textarea name="text" rows="20" cols="60"></textarea> <input type="submit" value="Submit text"> </form>
And there is a code that handles this message.
http.createServer(function (req, res) { var postData = ''; req.setEncoding('utf8'); req.addListener('data', function(postDataChunk) { postData += postDataChunk; console.log('Новые данные: ' + postDataChunk); }); req.addListener('end', function() { res.writeHead(200, {"Content-Type": "text/html"}); res.write("Вы загрузили:" + postData); res.end(); }); }).listen(1337,'127.0.0.1');
The message accepts, but displays in the wrong encoding (Cyrillic) in the form of all sorts of different kryakozyabr. UTF-8 page encoding (without BOM). Tell me, please, how to make the Cyrillic characters correctly output?