From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../reference/global_objects/encodeuricomponent/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html b/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html index dd30f152b1..2864496ff8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/encodeURIComponent

语法

-
encodeURIComponent(str);
+
encodeURIComponent(str);

参数

@@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/encodeURIComponent

encodeURIComponent 转义除了如下所示外的所有字符:

-
不转义的字符:
+
不转义的字符:
     A-Z a-z 0-9 - _ . ! ~ * ' ( )

encodeURIComponent()encodeURI 有以下几个不同点:

@@ -54,7 +54,7 @@ console.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encode

注意,如果试图编码一个非高-低位完整的代理字符,将会抛出一个 {{jsxref("URIError")}} 错误,例如:

-
// 高低位完整
+
// 高低位完整
 alert(encodeURIComponent('\uD800\uDFFF'));
 
 // 只有高位,将抛出"URIError: malformed URI sequence"
@@ -69,7 +69,7 @@ alert(encodeURIComponent('\uDFFF')); 

为了更严格的遵循 {{rfc("3986")}}(它保留 !, ', (, ), 和 *),即使这些字符并没有正式划定 URI 的用途,下面这种方式是比较安全的:

-
function fixedEncodeURIComponent (str) {
+
function fixedEncodeURIComponent (str) {
   return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
     return '%' + c.charCodeAt(0).toString(16).toUpperCase();
   });
@@ -79,7 +79,7 @@ alert(encodeURIComponent('\uDFFF')); 

下面这个例子提供了 UTF-8 下 {{HTTPHeader("Content-Disposition")}} 和 {{HTTPHeader("Link")}} 的服务器响应头信息的参数(例如 UTF-8 文件名):

-
var fileName = 'my file(2).txt';
+
var fileName = 'my file(2).txt';
 var header = "Content-Disposition: attachment; filename*=UTF-8''"
              + encodeRFC5987ValueChars(fileName);
 
-- 
cgit v1.2.3-54-g00ecf