メインコンテンツまでスキップ

5.1. 非 ASCII フィールド名と値

5.1. Non-ASCII Field Names and Values

🇬🇧 英文原文

Normally, MIME header fields in multipart bodies are required to consist only of 7-bit data in the US-ASCII character set. While [RFC2388] suggested that non-ASCII field names be encoded according to the method in [RFC2047], this practice doesn't seem to have been followed widely.

This specification makes three sets of recommendations for three different states of workflow.

🇯🇵 日本語訳

通常,マルチパート本体の MIME ヘッダーフィールドは,US-ASCII 文字セットの 7 ビットデータのみで構成されることが必須である。[RFC2388] では,[RFC2047] のメソッドに従って非 ASCII フィールド名をエンコードすることが提案されていたが,この慣行は広く採用されていないようである。

本仕様では,3 つの異なるワークフロー状態に対して 3 セットの推奨事項を示す。


5.1.1. Avoid Non-ASCII Field Names

🇬🇧 英文原文

For broadest interoperability with existing deployed software, those creating forms SHOULD avoid non-ASCII field names. This should not be a burden because, in general, the field names are not visible to users. The field names in the underlying need not match what the user sees on the screen.

If non-ASCII field names are unavoidable, form or application creators SHOULD use UTF-8 uniformly. This will minimize interoperability problems.

🇯🇵 日本語訳

既存の展開されたソフトウェアとの最も広範な相互運用性を実現するために,フォームを作成する者は非 ASCII フィールド名を避けるべきである (SHOULD)。一般的に,フィールド名はユーザーには表示されないため,これは負担にはならないはずである。基礎となるフィールド名は,ユーザーが画面上で見るものと一致する必要はない。

非 ASCII フィールド名が避けられない場合,フォームまたはアプリケーション作成者は UTF-8 を統一的に使用すべきである (SHOULD)。これにより,相互運用性の問題が最小限に抑えられる。


5.1.2. Interpreting Forms and Creating multipart/form-data Data

🇬🇧 英文原文

Some applications of this specification will supply a character encoding to be used for interpretation of the multipart/form-data body. In particular, HTML 5 [W3C.REC-html5-20141028] uses:

  • the content of a "charset" field, if there is one;
  • the value of an accept-charset attribute of the <form> element, if there is one;
  • the character encoding of the document containing the form, if it is US-ASCII compatible;
  • otherwise, UTF-8.

Call this value the form-charset. Any text, whether field name, field value, or ("text/plain") form data that uses characters outside the ASCII range MAY be represented directly encoded in the form-charset.

🇯🇵 日本語訳

本仕様の一部のアプリケーションは,multipart/form-data 本体の解釈に使用される文字エンコーディングを提供する。特に,HTML 5 [W3C.REC-html5-20141028] は次を使用する:

  • "charset" フィールドのコンテンツ(存在する場合);
  • <form> 要素の accept-charset 属性の値(存在する場合);
  • フォームを含むドキュメントの文字エンコーディング(US-ASCII 互換の場合);
  • それ以外の場合は UTF-8。

この値を form-charset と呼ぶ。フィールド名,フィールド値,または ASCII 範囲外の文字を使用する ("text/plain") フォームデータであるかどうかにかかわらず,任意のテキストは form-charset で直接エンコードして表現してもよい (MAY)。


5.1.3. Parsing and Interpreting Form Data

🇬🇧 英文原文

While this specification provides guidance for the creation of multipart/form-data, parsers and interpreters should be aware of the variety of implementations. File systems differ as to whether and how they normalize Unicode names, for example. The matching of form elements to form-data parts may rely on a fuzzier match. In particular, some multipart/form-data generators might have followed the previous advice of [RFC2388] and used the "encoded-word" method of encoding non-ASCII values, as described in [RFC2047]:

encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

Others have been known to follow [RFC2231], to send unencoded UTF-8, or even to send strings encoded in the form-charset.

For this reason, interpreting multipart/form-data (even from conforming generators) may require knowing the charset used in form encoding in cases where the charset field value or a charset parameter of a "text/plain" Content-Type header field is not supplied.

🇯🇵 日本語訳

本仕様は multipart/form-data の作成に関するガイダンスを提供しているが,パーサーとインタープリターは実装の多様性を認識すべきである。例えば,ファイルシステムは Unicode 名を正規化するかどうか,またどのように正規化するかが異なる。フォーム要素とフォームデータ部分のマッチングは,より曖昧なマッチングに依存する場合がある。特に,一部の multipart/form-data ジェネレーターは [RFC2388] の以前のアドバイスに従い,[RFC2047] で説明されている "encoded-word" メソッドを使用して非 ASCII 値をエンコードしている可能性がある:

encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

他の実装は [RFC2231] に従ったり,エンコードされていない UTF-8 を送信したり,さらには form-charset でエンコードされた文字列を送信したりすることが知られている。

このため,charset フィールド値または "text/plain" Content-Type ヘッダーフィールドの charset パラメータが提供されていない場合,multipart/form-data の解釈(準拠したジェネレーターからのものであっても)には,フォームエンコーディングで使用される charset を知る必要がある場合がある。