From 74577745f69e41b60fc845dcfe2934ac664686a9 Mon Sep 17 00:00:00 2001 From: Sean Sun Date: Thu, 13 Oct 2016 18:15:16 +0800 Subject: [PATCH] chapter punycode is done --- README.md | 2 +- doc/about.md | 2 ++ doc/punycode.md | 71 +++---------------------------------------------- 3 files changed, 6 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 1a5bb44..15ab11b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ | OS | 翻译中... | | Path | 翻译中... | | Process | 翻译中... | -| Punycode | 翻译中... | +| Punycode | 已完成 | | Query Strings | 翻译中... | | Readline | 翻译中... | | REPL | 翻译中... | diff --git a/doc/about.md b/doc/about.md index 14c2599..44e3ba7 100644 --- a/doc/about.md +++ b/doc/about.md @@ -20,6 +20,8 @@ 模块已锁定,不接受新的 API 建议,后续只会进行安全、性能或 Bug 方面的优化。 +> 本文档不会翻译稳定性为 0 的模块,也不建议使用此类模块。 + ## 系统调用和 man 页面 类似 [open(2)](http://man7.org/linux/man-pages/man2/open.2.html) 和 [read(2)](http://man7.org/linux/man-pages/man2/read.2.html) 的系统调用命令定义了用户程序与底层操作系统之间的接口。对于 Node.js 简单封装的系统调用命令都会在文档中显式标注,比如 `fs.open()`。对于系统调用命令,文档会直接链接到相应的 man 页面。 diff --git a/doc/punycode.md b/doc/punycode.md index 0e19f61..5f57bf3 100644 --- a/doc/punycode.md +++ b/doc/punycode.md @@ -1,73 +1,8 @@ ## Punycode -
+
-Node.js 自 v0.6.2 版本加入了 [Punycode.js](https://mths.be/punycode),通过 `require('punycode')` 的方式访问。 - -## punycode.decode(string) - -将一个纯 ASCII 的 Punycode 字符串转换为 Unicode 字符串: - -```js -// decode domain name parts -punycode.decode('maana-pta'); // 'mañana' -punycode.decode('--dqo34k'); // '☃-⌘' -``` - -## punycode.encode(string) - -将一个 Unicode 字符串转换为纯 ASCII 的 Punycode 字符串: - -```js -// encode domain name parts -punycode.encode('mañana'); // 'maana-pta' -punycode.encode('☃-⌘'); // '--dqo34k' -``` - -## punycode.toASCII(domain) - -将一个 Unicode 域名字符串转换为 Punycode 字符串,域名中只有非 ASCII 的部分会被转换: - -```js -// encode domain names -punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' -punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' -``` - -## punycode.toUnicode(domain) - -将一个 Punycode 的域名字符串转换为 Unicode 字符串,域名中只有 Punycode 的部分会被转换: - -```js -// decode domain names -punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' -punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' -``` - -## punycode.ucs2 - -#### punycode.ucs2.decode(string) - -根据传入的 `string` 参数创建一个数值形式的编码数组。由于 JavaScript 内部使用 UCS-2,所以该函数会根据 UTF-16 将一对 surrogate halves 转换为一个编码: - -```js -punycode.ucs2.decode('abc'); // [0x61, 0x62, 0x63] -// surrogate pair for U+1D306 tetragram for centre: -punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] -``` - -## punycode.ucs2.encode(codePoints) - -将编码数组转换为字符串: - -```js -punycode.ucs2.encode([0x61, 0x62, 0x63]); // 'abc' -punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06' -``` - -## punycode.version - -返回字符串形式的 Punycode 版本号。 +punycode 模块已废弃,如果需要使用该模块,可以安装开源社区提供的 [Punycode.js](https://mths.be/punycode)。 \ No newline at end of file +