當內容類型爲application/x-www-form-urlencoded
時,是否習慣於省略;charset="utf-8"
?application/x-www-form-urlencoded和charset =「utf-8」?
特別是,在表單標籤中使用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>
而標頭生成的請求是:
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
什麼是用於指定形式參數值是如何編碼的約定?
哦,有趣的消息我不知道:*「如果條目的名稱是」_charset_「,並且它的類型是」hidden「,則用charset替換它的值。「* – deceze
請注意,您正在鏈接到** HTML 5 **規範,但所討論的HTML正在使用** HTML 4 **。下面是HTML 4的表單提交算法:http://www.w3 .org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13,儘管它沒有談論字符集處理。 –
Remy:doctype不會影響瀏覽器在表單編碼方面做些什麼。 –