I need to pull the HTML from any given website with a network request and display it, the problem is that by the differences in character encoding some websites content characters would not display the right way.
My current code look like this: (Have in count that this is a server-side code)
const response = await fetch(url);
const buffer = await response.arrayBuffer();
const decoder = new TextDecoder("iso-8859-15");
const decoded = decoder.decode(buffer);
However neither iso-8859-15 or utf-8 work for all the websites.
So I would need a dynamic way to know the correct one for each website