Punycode
¥Stability: 0 - Deprecated
源代码: lib/punycode.js
Node.js 中打包的 punycode 模块版本已被弃用。在 Node.js 的未来主版本中,此模块将被删除。当前依赖 punycode
模块的用户应该改用用户空间提供的 Punycode.js 模块。对于基于 punycode 的 URL 编码,请参阅 url.domainToASCII
或更一般地说,WHATWG URL API。
¥The version of the punycode module bundled in Node.js is being deprecated.
In a future major version of Node.js this module will be removed. Users
currently depending on the punycode
module should switch to using the
userland-provided Punycode.js module instead. For punycode-based URL
encoding, see url.domainToASCII
or, more generally, the
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 字符,因此必须使用 Punycode 方案将包含非 ASCII 字符的域名转换为 ASCII。例如,翻译成英文单词的日字面符 'example'
是 '例'
。国际化域名 '例.com'
(相当于 'example.com'
)由 Punycode 表示为 ASCII 字符串 'xn--fsq.com'
。
¥Punycode is a character encoding scheme defined by RFC 3492 that is
primarily intended for use in Internationalized Domain Names. Because host
names in URLs are limited to ASCII characters only, Domain Names that contain
non-ASCII characters must be converted into ASCII using the Punycode scheme.
For instance, the Japanese character that translates into the English word,
'example'
is '例'
. The Internationalized Domain Name, '例.com'
(equivalent
to 'example.com'
) is represented by Punycode as the ASCII string
'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.