ruby idna.toUnicode 的乐趣在于,它不会转换 tld 部分中的 punycode

发布于 2024-09-29 22:41:31 字数 241 浏览 0 评论 0原文

我使用 Idna.toAscii 函数来转换网站名称 www.中国.中国(顶级域名也有 unicode 字符)。

结果是 www.xn--fiqs8s.xn--fiqs8s

我使用 Idna.toUnicode fun 将上面的 punycode 转换回 unicode 字符。

但我只得到www.中国.xn--fiqs8s toUnicode 的乐趣在于忽略 tld 部分。

有什么办法可以克服这个吗?

i use the Idna.toAscii fun to convert a site name www.中国.中国(the tld is also has unicode chars).

the result was www.xn--fiqs8s.xn--fiqs8s

I used the Idna.toUnicode fun to convert the above punycode back to the unicode characters.

but i got only www.中国.xn--fiqs8s
The toUnicode fun is ignoring the tld part.

Is there any way to over come this?

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

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

发布评论

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

评论(1

你又不是我 2024-10-06 22:41:31

IDN::Idna.toUnicode("www.xn--fiqs8s.xn--fiqs8s") 为我生成“www.中国.中国”。

我有 0.0.2 版的 ruby​​ idn gem 和 1.19 版的 LibIDN,您是否需要更新其中之一?

IDN::Idna.toUnicode("www.xn--fiqs8s.xn--fiqs8s") produces "www.中国.中国" for me.

I have version 0.0.2 of the ruby idn gem and version 1.19 of LibIDN, do you perhaps need to update one of these?

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