url.domainToUnicode(domain)


返回 domain 的 Unicode 序列化。如果 domain 是无效的域名,则返回空字符串。

🌐 Returns the Unicode serialization of the domain. If domain is an invalid domain, the empty string is returned.

它执行与 url.domainToASCII() 相反的操作。

🌐 It performs the inverse operation to url.domainToASCII().

此功能仅在 node 可执行文件在编译时启用了 重症监护室 的情况下可用。如果未启用,域名将原样传递。

🌐 This feature is only available if the node executable was compiled with ICU enabled. If not, the domain names are passed through unchanged.

import url from 'node:url';

console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty stringconst url = require('node:url');

console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty string