【问题标题】:fetch response replaces Hebrew with question marks in black diamondsfetch response 用黑色菱形问号替换希伯来语
【发布时间】:2019-07-17 00:13:48
【问题描述】:
 const fetch = require("node-fetch")

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

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

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

【问题讨论】:

  • 您能提供一个示例网址吗?

标签: node.js character-encoding fetch node-fetch


【解决方案1】:

默认情况下 (res.text()) 假定已使用 utf8,但正如 this issue 所指出的,情况并非总是如此。 可能是你的情况,在这种情况下你可能想尝试用res.textConverted()替换res.text(),以便在转换为字符串之前执行编码嗅探。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多