var text = "Привет"; request("http://site.ru/i.php?t="+text, function(error, res, body){ console.log(body); }); Displays: @825B
I.php file:
<?php error_reporting(E_ERROR); header('Content-type: text/html; charset=utf-8'); echo $_GET["t"]; ?> var text = "Привет"; request("http://site.ru/i.php?t="+text, function(error, res, body){ console.log(body); }); Displays: @825B
I.php file:
<?php error_reporting(E_ERROR); header('Content-type: text/html; charset=utf-8'); echo $_GET["t"]; ?> Always explicitly encode the data.
https://github.com/nodejs/node/issues/1693
The problem is approximately in this piece of code: https://github.com/nodejs/node/blob/v4.x/lib/_http_outgoing.js#L131-L134
As a result, your request is recoded as binary and it turns out such a mess:
> new Buffer('Привет', 'binary').toString() '\u001f@825B' It should work
request("http://site.ru/i.php?t=" + encodeURIComponent(text), Source: https://ru.stackoverflow.com/questions/572499/
All Articles
console.log(typeof body)display? - Dmitriy Simushevecho $_GET['t']withecho iconv('cp1251', 'utf-8', $_GET['t']);? - Dmitriy Simushev 1:09 pm