Answer the question
In order to leave comments, you need to log in
How to convert encoding from windows-1251 to UTF-8 in node.js?
I don’t understand why it doesn’t work
There is a page with charset=windows-1251
I get text from it using jsdom �����
I try to convert
var iconv = new Iconv('windows-1251', 'UTF-8');
var x = iconv.convert(text);
console.log(x.toString());
pїЅpїЅpїЅpїЅpїЅ
Answer the question
In order to leave comments, you need to log in
Here the problem is not with the conversion, but with the output of utf-8 text from the node on Windows: https://github.com/nodejs/node-v0.x-archive/issues/2190
In short: run chcp 65001 in the console before starting the process node.exe
I had the same problem when getting html via request and fetch. Found a way out through the needle
If you need to determine an encoding that is unknown, then for Cyrillic texts here: https://github.com/nickkolok/node-autodetect-utf8-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question