I need to convert a string from Windows-1251 to UTF-8.
I tried to do this with iconv, but all I get is something like this:
пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ
var iconv = new Iconv('windows-1251', 'utf-8')
title = iconv.convert(title).toString('utf-8')
Here is working solution to your problem. You have to use Buffer and convert your string to binary first.
const Iconv = require('iconv').Iconv;
request({
uri: website_url,
method: 'GET',
encoding: 'binary'
}, function (error, response, body) {
const body = new Buffer(body, 'binary');
conv = Iconv('windows-1251', 'utf8');
body = conv.convert(body).toString();
});
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