aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/accept-charset/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/accept-charset/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/accept-charset/index.html')
-rw-r--r--files/zh-cn/web/http/headers/accept-charset/index.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/accept-charset/index.html b/files/zh-cn/web/http/headers/accept-charset/index.html
new file mode 100644
index 0000000000..151a09575d
--- /dev/null
+++ b/files/zh-cn/web/http/headers/accept-charset/index.html
@@ -0,0 +1,90 @@
+---
+title: Accept-Charset
+slug: Web/HTTP/Headers/Accept-Charset
+tags:
+ - HTTP
+ - HTTP Header
+ - POST
+ - Request header
+ - 内容协商
+ - 请求头
+translation_of: Web/HTTP/Headers/Accept-Charset
+---
+<div>{{HTTPSidebar}}</div>
+
+<p><strong><code>Accept-Charset</code></strong> 请求头用来告知(服务器)客户端可以处理的字符集类型。 借助<a href="/en-US/docs/Web/HTTP/Content_negotiation">内容协商机制</a>,服务器可以从诸多备选项中选择一项进行应用, 并使用{{HTTPHeader("Content-Type")}} 应答头通知客户端它的选择。浏览器通常不会设置此项值,因为每种内容类型的默认值通常都是正确的,但是发送它会更有利于识别。</p>
+
+<p>如果服务器不能提供任何可以匹配的字符集的版本,那么理论上来说应该返回一个 {{HTTPStatus("406")}} (Not Acceptable,不被接受)的错误码。但是为了更好的用户体验,这种方法很少采用,取而代之的是将其忽略。</p>
+
+<div class="note">
+<p>在早期版本的HTTP/1.1协议中,规定了一个默认的字符集(ISO-8859-1)。但是现在情况不同了,目前每一种内容类型都有自己的默认字符集。</p>
+</div>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">Header type</th>
+ <td>{{Glossary("Request header")}}</td>
+ </tr>
+ <tr>
+ <th scope="row">{{Glossary("Forbidden header name")}}</th>
+ <td>yes</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="句法">句法</h2>
+
+<pre class="syntaxbox">Accept-Charset: &lt;charset&gt;
+
+// Multiple types, weighted with the {{glossary("quality values", "quality value")}} syntax:
+Accept-Charset: utf-8, iso-8859-1;q=0.5</pre>
+
+<h2 id="指令">指令</h2>
+
+<dl>
+ <dt><code>&lt;charset&gt;</code></dt>
+ <dd><code>诸如 utf-8</code> 或 <code>iso-8859-15的字符集。</code></dd>
+ <dt><code>*</code></dt>
+ <dd><code><font face="Open Sans, arial, sans-serif">在这个消息头中未提及的任意其他字符集;</font>'*'</code> 用来表示通配符。</dd>
+ <dt><code>;q=</code> (q-factor weighting)</dt>
+ <dd>值代表优先顺序,用相对<a href="/en-US/docs/Glossary/Quality_values">质量价值</a>表示,又称为权重。</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<pre>Accept-Charset: iso-8859-1
+
+Accept-Charset: utf-8, iso-8859-1;q=0.5
+
+Accept-Charset: utf-8, iso-8859-1;q=0.5, *;q=0.1
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Title</th>
+ </tr>
+ <tr>
+ <td>{{RFC("7231", "Accept-Charset", "5.3.3")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("http.headers.Accept-Charset")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>HTTP <a href="/en-US/docs/Web/HTTP/Content_negotiation">内容协商机制</a></li>
+ <li>用来表示内容协商结果的消息头: {{HTTPHeader("Content-Type")}}</li>
+ <li>其他类似消息头: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept-Encoding")}}, {{HTTPHeader("Accept-Language")}}, {{HTTPHeader("Accept")}}</li>
+</ul>