What is encoding for czech characters when downloading from web

330 views Asked by At

I am downloading page from web in node.js using standard request library and the czech characters are not processed correctly.

I have tried utf-8, ISO-8859-1, latin1, latin2 and few others encoding that was suggested by some other page but nothing works.

This is the code I am using:

const request = require("request-promise-native");
const iconv = require("iconv-lite");

async function run() {
  const data = await request({
    encoding: null,
    method: "GET",
    uri: "yourpage.com"
  });

  const body = iconv.decode(data, "ISO-8859-1");
  console.log(body);
}

run().catch(console.log);

1

There are 1 answers

0
libik On

some of the czech pages are encoded in cp1250, try it and it should work if all other encoding failed.

const request = require("request-promise-native");
const iconv = require("iconv-lite");

async function run() {
  const data = await request({
    encoding: null,
    method: "GET",
    uri: "yourpage.com"
  });

  const body = iconv.decode(data, "cp1250");
  console.log(body);
}

run().catch(console.log);