fetch response 将希伯来语替换为黑色菱形问号

fetch response replaces Hebrew with question marks in black diamonds

 const fetch = require("node-fetch")

 fetch("https://www.example.com")
 .then(res => res.text())
 .then(data => console.log(data))

输出为 HTML 字符串,但希伯来语单词替换为 ���� ����

如何设置正确的编码以正确显示希伯来语文本? 最终目标是检查多个网站是否包含某些希伯来语关键字。

默认情况下 (res.text()) 假定已使用 utf8,但是,正如 this issue, it's not always the case. That might be your case, in which case you might want to try replacing res.text() by res.textConverted() 所指出的那样,以便在转换为字符串之前执行编码嗅探。