Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms application/x-www-form-urlencoded和charset=";utf-8“;?_Forms_Http_Post_Encoding_Utf 8 - Fatal编程技术网

Forms application/x-www-form-urlencoded和charset=";utf-8“;?

Forms application/x-www-form-urlencoded和charset=";utf-8“;?,forms,http,post,encoding,utf-8,Forms,Http,Post,Encoding,Utf 8,是否习惯省略;charset=“utf-8”当内容类型为application/x-www-form-urlencoded时 特别是,当在表单标记中使用accept charset=“utf-8”时,我希望在标题中使用utf-8,但我没有看到任何指示 下面是我对Chrome的简单测试。表格页为: <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> &

是否习惯省略
;charset=“utf-8”
当内容类型为
application/x-www-form-urlencoded

特别是,当在表单标记中使用
accept charset=“utf-8”
时,我希望在标题中使用utf-8,但我没有看到任何指示

下面是我对Chrome的简单测试。表格页为:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<form method="POST" action="printenv.cgi" accept-charset="utf-8">
Your name:
<input name="name" type="text" size="30">
</form>
</body>
</html>
指定表单参数值编码方式的约定是什么

  • 没有为此媒体类型定义字符集参数

  • 有关编码准则,请参阅

  • 应用程序/x-www-form-urlencoded
    标准意味着UTF-8和百分比编码

    尽管:

    传统的面向服务器的实现可能必须支持 UTF-8以外的编码,以及对 它的名称是
    \u charset
    。这种逻辑在这里并不是仅描述为 UTF-8符合要求


    注意:在上面链接的步骤2中,它说:“否则,让所选字符编码为UTF-8” (见:)

    我还认为,这似乎表明用户代理使用UTF-8是一种最佳实践?

    它是这样说的: B.2.1 URI属性值中的非ASCII字符

    尽管URI不包含非ASCII值(参见[URI],第2.1节),但作者有时会在预期URI的属性值中指定它们(即,在DTD中用%URI;定义)。例如,以下href值是非法的:

    我们建议用户代理在这种情况下采用以下约定来处理非ASCII字符:

    Represent each character in UTF-8 (see [RFC2279]) as one or more bytes.
    Escape these bytes with the URI escaping mechanism (i.e., by converting each byte to %HH, where HH is the hexadecimal notation of the byte value).
    
    此过程产生语法合法的URI(如[RFC1738]第2.2节或[RFC2141]第2节中的定义),该URI独立于携带URI的HTML文档可能已被转码到的字符编码

    注意。一些较老的用户代理使用接收文档时的字符编码字节来处理HTML中的URI。一些旧的HTML文档依赖于这种做法,在转码时会中断。希望处理这些旧文档的用户代理在接收到包含合法集以外字符的URI时,应首先使用基于UTF-8的转换。只有当结果URI没有解析时,他们才应该尝试基于接收文档的字符编码字节构造URI


    注意。基于UTF-8的相同转换应该应用于A元素的name属性的值。

    Oh,有趣的小贴士我不知道:“如果条目的名称为“\u charset\u”,并且它的类型为“hidden”,请用charset替换它的值。”注意,您正在链接到HTML5规范,但所讨论的HTML使用的是HTML4。下面是HTML4:的表单提交算法,但它没有讨论字符集处理。Remy:doctype不影响浏览器对表单编码的操作。
    Represent each character in UTF-8 (see [RFC2279]) as one or more bytes.
    Escape these bytes with the URI escaping mechanism (i.e., by converting each byte to %HH, where HH is the hexadecimal notation of the byte value).