- Assertion testing
- Asynchronous context tracking
- Async hooks
- Buffer
- C++ addons
- C/C++ addons with Node-API
- C++ embedder API
- Child processes
- Cluster
- Command-line options
- Console
- Corepack
- Crypto
- Debugger
- Deprecated APIs
- Diagnostics Channel
- DNS
- Domain
- Errors
- Events
- File system
- Globals
- HTTP
- HTTP/2
- HTTPS
- Inspector
- Internationalization
- Modules: CommonJS modules
- Modules: ECMAScript modules
- Modules:
node:module
API - Modules: Packages
- Net
- OS
- Path
- Performance hooks
- Permissions
- Process
- Punycode
- Query strings
- Readline
- REPL
- Report
- Stream
- String decoder
- Test runner
- Timers
- TLS/SSL
- Trace events
- TTY
- UDP/datagram
- URL
- Utilities
- V8
- VM
- WASI
- Web Crypto API
- Web Streams API
- Worker threads
- Zlib
Node.js v18.12.1 documentation
- Node.js v18.12.1
- ► Table of contents
-
► Index
- Assertion testing
- Asynchronous context tracking
- Async hooks
- Buffer
- C++ addons
- C/C++ addons with Node-API
- C++ embedder API
- Child processes
- Cluster
- Command-line options
- Console
- Corepack
- Crypto
- Debugger
- Deprecated APIs
- Diagnostics Channel
- DNS
- Domain
- Errors
- Events
- File system
- Globals
- HTTP
- HTTP/2
- HTTPS
- Inspector
- Internationalization
- Modules: CommonJS modules
- Modules: ECMAScript modules
- Modules:
node:module
API - Modules: Packages
- Net
- OS
- Path
- Performance hooks
- Permissions
- Process
- Punycode
- Query strings
- Readline
- REPL
- Report
- Stream
- String decoder
- Test runner
- Timers
- TLS/SSL
- Trace events
- TTY
- UDP/datagram
- URL
- Utilities
- V8
- VM
- WASI
- Web Crypto API
- Web Streams API
- Worker threads
- Zlib
- ► Other versions
- ► Options
Table of contents
Punycode#
Source Code: lib/punycode.js
The version of the punycode module bundled in Node.js is being deprecated.Node.js中捆绑的punycode模块版本正在被弃用。 In a future major version of Node.js this module will be removed. 在Node.js的未来主要版本中,此模块将被删除。Users currently depending on the 当前依赖punycode
module should switch to using the userland-provided Punycode.js module instead. punycode
模块的用户应该改用userland提供的Punycode.js模块。For punycode-based URL encoding, see 有关基于punycode的URL编码,请参阅url.domainToASCII
or, more generally, the WHATWG URL API.url.domainToASCII
,或者更一般地,WHATWG URL API。
The punycode
module is a bundled version of the Punycode.js module. punycode
模块是Punycode.js模块的捆绑版本。It can be accessed using:可通过以下方式访问:
const punycode = require('punycode');
Punycode is a character encoding scheme defined by RFC 3492 that is primarily intended for use in Internationalized Domain Names. 是RFC 3492定义的字符编码方案,主要用于国际化域名。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. 由于URL中的主机名仅限于ASCII字符,因此必须使用Punycode方案将包含非ASCII字符的域名转换为ASCII。For instance, the Japanese character that translates into the English word, 例如,翻译成英语单词'example'
is '例'
. 'example'
的日语字符是'例'
。The Internationalized Domain Name, 国际化域名'例.com'
(equivalent to 'example.com'
) is represented by Punycode as the ASCII string 'xn--fsq.com'
.'例.com'
(相当于'example.com'
)由Punycode表示为ASCII字符串'xn--fsq.com'
。
The punycode
module provides a simple implementation of the Punycode standard.punycode
模块提供了punycode标准的简单实现。
The punycode
module is a third-party dependency used by Node.js and made available to developers as a convenience. punycode
模块是Node.js使用的第三方依赖项,为开发人员提供方便。Fixes or other modifications to the module must be directed to the Punycode.js project.对模块的修复或其他修改必须指向Punycode.js项目。