CGI::unescapeHTML 问题

发布于 2024-10-01 08:27:05 字数 321 浏览 0 评论 0原文

CGI::unescapeHTML("渣打银")

=> "渣打\351\223\266"

CGI::unescapeHTML("渣打银 ")

=> “渣打银”

在末尾添加一个空格会有所不同,否则最后一个字符会丢失,我会得到这个奇怪的字符序列。当我尝试使用 utf-8 字符编码从网站上抓取数据时,我遇到了这个问题。即使对于普通的英文文本也是如此。

CGI::unescapeHTML("渣打银")

=> "渣打\351\223\266"

CGI::unescapeHTML("渣打银 ")

=> "渣打银 "

Adding a space at the end makes the difference, else the last character is lost and I get this strange character sequence. I am facing this very issue when I try to scrape data form websites using utf-8 character encoding. This is true even for normal english text.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

︶葆Ⅱㄣ 2024-10-08 08:27:06

对于 Ruby 1.9.2 及更高版本附带的 CGI 库来说,这不是问题。

This is not a problem with the CGI library that comes with Ruby 1.9.2 and above.

情域 2024-10-08 08:27:06

使用 -Ku 运行您的 Ruby 解释器

Run your ruby interpreter with -Ku

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文