Punycode
源代码: lib/punycode.js
Node.js 中打包的 punycode 模块版本即将被弃用。
在未来的 Node.js 主要版本中,该模块将被移除。目前依赖 punycode 模块的用户应切换使用用户社区提供的 Punycode.js 模块。对于基于 punycode 的 URL 编码,请参见 url.domainToASCII,或更一般地,参见 WHATWG URL API。
punycode 模块是 Punycode.js 模块的打包版本。可以通过以下方式访问:
【The punycode module is a bundled version of the Punycode.js module. It
can be accessed using:】
const punycode = require('node:punycode'); Punycode 是由 RFC 3492 定义的一种字符编码方案,主要用于国际化域名。由于 URL 中的主机名仅限于使用 ASCII 字符,因此包含非 ASCII 字符的域名必须使用 Punycode 方案转换为 ASCII。例如,表示英文单词 'example' 的日文字符是 '例'。国际化域名 '例.com'(相当于 'example.com')在 Punycode 中表示为 ASCII 字符串 'xn--fsq.com'。
punycode 模块提供了 Punycode 标准的简单实现。
【The punycode module provides a simple implementation of the Punycode standard.】
punycode 模块是 Node.js 使用的第三方依赖,并作为一种便利提供给开发者。对该模块的修复或其他修改必须提交给 Punycode.js 项目。
【The punycode module is a third-party dependency used by Node.js and
made available to developers as a convenience. Fixes or other modifications to
the module must be directed to the Punycode.js project.】