【问题标题】:Cannot get json/text in nodejs when url contains weird unicode characters当 url 包含奇怪的 unicode 字符时,无法在 nodejs 中获取 json/text
【发布时间】:2019-03-04 19:28:08
【问题描述】:

所以我一直在使用 get-json 模块从远程 url 获取 json。但是每次我给它一个带有奇怪 unicode 字符的 url 时,它都会失败并给出一个错误。我尝试了许多其他模块,但它们也都失败了。当 url 包含奇怪的 unicode 字符时,我可以使用什么从远程 url 获取 text/json?

【问题讨论】:

    标签: node.js unicode


    【解决方案1】:

    您必须将 unicode 字符转换为 Punycode

    例如?☁.ws一旦转换为https://xn--l3hz130o.ws

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-06
      • 2014-04-09
      • 1970-01-01
      • 1970-01-01
      • 2013-03-13
      • 2012-12-24
      • 1970-01-01
      相关资源
      最近更新 更多