const fetch = require("node-fetch")
fetch("https://www.example.com")
.then(res => res.text())
.then(data => console.log(data))
输出是 HTML 字符串,但希伯来语单词替换为 ���� ����
如何设置正确的编码以正确显示希伯来语文本?最终目标是检查多个网站是否包含某个希伯来语关键字。
const fetch = require("node-fetch")
fetch("https://www.example.com")
.then(res => res.text())
.then(data => console.log(data))
输出是 HTML 字符串,但希伯来语单词替换为 ���� ����
如何设置正确的编码以正确显示希伯来语文本?最终目标是检查多个网站是否包含某个希伯来语关键字。
默认情况下 ( ) 假定已使用 utf8,但正如本期res.text()
所指出的,情况并非总是如此。这可能是您的情况,在这种情况下,您可能想尝试替换为以便在转换为字符串之前执行编码嗅探。res.text()
res.textConverted()