N
N
Nikita Gusakov2013-12-11 16:22:41
Character encoding
Nikita Gusakov, 2013-12-11 16:22:41

How to handle win-1251 in http.get response?

There is some API, which is given in 1251 encoding. http.get in req.on('data', ...) returns buffer, buffer node does not support 1251 encoding, what should I do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gusakov, 2013-12-11
@hell0w0rd

var iconv = new Iconv('windows-1251', 'UTF-8');
http.get(url, function (res) {
  res.on('data', function (buffer) {
    var html = iconv.convert(buffer).toString();
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question