application / x-www-form-urlencoded and charset =“utf-8”? [英] application/x-www-form-urlencoded and charset="utf-8"?

查看:168
本文介绍了application / x-www-form-urlencoded and charset =“utf-8”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当内容类型为 application / x-www-form-urlencoded时,通常省略; charset =utf-8



特别是当使用 accept-charset =utf-8在表单标签中,我希望有一些迹象表明utf-8正在头文件中使用,但我没有看到任何内容。



这是我简单的测试铬。表单页面是:

 < html> 
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< / head>
< body>
< form method =POSTaction =printenv.cgiaccept-charset =utf-8>
您的姓名:
< input name =nametype =textsize =30>
< / form>
< / body>
< / html>

生成的请求的标题是:

  POST /printenv.cgi HTTP / 1.1 
主机:...:8000
连接:keep-alive
Content-Length:19
缓存控制:max-age = 0
接受:text / html,application / xhtml + xml,application / xml; q = 0.9,* / *; q = 0.8
原产地:http :// ...:8000
用户代理:Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 537.36(KHTML,像Gecko)Chrome / 27.0.1453.94 Safari / 537.36
内容类型:application / x-www-form-urlencoded
引用:http:// ...:8000 / utf8-test.html
接受编码:gzip,deflate,sdch
Accept-语言:en-US,en; q = 0.8

指定表单参数值的方式是什么编码?

解决方案

1)没有为此媒体类型定义的charset参数。



2)有关编码指南,请参阅 http://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm 。 p>

Is it customary to omit ;charset="utf-8" when the Content-type is application/x-www-form-urlencoded?

In particular, when using accept-charset="utf-8" in a form tag, I would expect some indication that utf-8 is being used in the headers, but I'm not seeing any.

Here is my simple test in Chrome. The form page is:

<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>

And the headers for the generated request are:

POST /printenv.cgi HTTP/1.1
Host: ...:8000
Connection: keep-alive
Content-Length: 19
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://...:8000
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://...:8000/utf8-test.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

What's the convention for specifying how the form parameter values are encoded?

解决方案

1) There is no charset parameter defined for this media type.

2) For the encoding guidelines, see http://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm.

这篇关于application / x-www-form-urlencoded and charset =“utf-8”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆