How can I send the following query in win1251 charset?
var getData = querystring.stringify({
type: "тест", note: "тест1"
}),
options = {
host: config.host,
path: config.path + '?' + getData,
method: 'GET'
};
http.request(options, function (res) {...}).end();
I think this snippet can help you
request({
uri: website_url,
method: 'GET',
encoding: 'binary'
}, function (error, response, body) {
body = new Buffer(body, 'binary');
conv = new iconv.Iconv('windows-1251', 'utf8');
body = conv.convert(body).toString();
}
});
Update 1
OK, i think find something useful :)
Please check out this link
You can use above utility like this
// Suppose gbkEncodeURIComponent function already exists,
// it can encode string with `gbk` encoding
querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
{ encodeURIComponent: win2unicode })
// returns
'w=%D6%D0%CE%C4&foo=bar'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With