multipart / form-data,字段的默认字符集是什么? [英] multipart/form-data, what is the default charset for fields?

查看:596
本文介绍了multipart / form-data,字段的默认字符集是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果没有给出字符集,应该使用什么来解码multipart / form-data的默认编码? RFC2388声明:

what is the default encoding one should use to decode multipart/form-data if no charset is given? RFC2388 states:


4.5表单数据中的文本字符集

4.5 Charset of text in form data

每个部分multipart / form-data应该有一个content-
类型。在field元素为text的情况下,文本的charset
参数表示使用的字符编码。

Each part of a multipart/form-data is supposed to have a content- type. In the case where a field element is text, the charset parameter for the text indicates the character encoding used.

例如,带有文本字段的表单其中用户键入'Joe欠
< eu> 100',其中< eu>是欧元符号可能有表格数据返回
as:

For example, a form with a text field in which a user typed 'Joe owes <eu>100' where <eu> is the Euro symbol might have form data returned as:

--AaB03x
content-disposition: form-data; name="field1"
content-type: text/plain;charset=windows-1250
content-transfer-encoding: quoted-printable>>

Joe owes =80100.
--AaB03x


在我的情况下,charset未设置,我不知道如何解码该text / plain部分中的数据。因为我不想强制执行不是标准行为的事情,所以我在问这个案例中的预期行为是什么。 RFC似乎没有解释这一点,所以我有点迷失。

In my case, the charset isn't set and I don't know how to decode the data within that text/plain section. As I do not want to enforce something that isn't standard behavior I'm asking what the expected behavior in this case is. The RFC does not seem to explain this so I'm kinda lost.

谢谢!

推荐答案

HTTP 1.1 的默认字符集是ISO-8859- 1(Latin1),我猜这也适用于此。

The default charset for HTTP 1.1 is ISO-8859-1 (Latin1), I would guess that this also applies here.


3.7.1规范化和文本默认值

3.7.1 Canonicalization and Text Defaults

- snip -

--snip--


使用charset参数使用某些媒体类型来定义数据的字符集(第3.4节)。当发送方未提供显式字符集参数时,文本类型的媒体子类型被定义为在通过HTTP接收时具有默认字符集值ISO-8859-1。除ISO-8859-1或其子集之外的字符集中的数据必须用适当的字符集值标记。有关兼容性问题,请参阅第3.4.1节。

The "charset" parameter is used with some media types to define the character set (section 3.4) of the data. When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. See section 3.4.1 for compatibility problems.

这篇关于multipart / form-data,字段的默认字符集是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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