<h2 class="no-num no-toc">Draft Standard — 11 October 2010</h2>
<h2 class="no-num no-toc">Draft Standard — 12 October 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
algorithm</dfn> is to encode the <var title="">form data set</var>
using the rules described by RFC2388, <cite>Returning Values from
Forms: <code title="">multipart/form-data</code></cite>, and return
the resulting byte stream. <a href=#refsRFC2388>[RFC2388]</a></p>
algorithm</dfn> is as follows:</p>
<p>Each entry in the <var title="">form data set</var> is a
<i>field</i>, the name of the entry is the <i>field name</i> and the
value of the entry is the <i>field value</i>, unless the entry's
name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and its type is "<code title="">hidden</code>", in which case the <i>field value</i> is the
character encoding used by the aforementioned algorithm to encode
the value of the field.</p>
<ol><!-- the first few steps of this are the same as in the previous section --><li><p>Let <var title="">result</var> be the empty string.</li>
<p>The order of parts must be the same as the order of fields in the
<var title="">form data set</var>. Multiple entries with the same
name must be treated as distinct fields.</p>
<li>
</div>
<p>If the <code><a href=#the-form-element>form</a></code> element has an <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute,
then, taking into account the characters found in the <var title="">form data set</var>'s names and values, and the character
encodings supported by the user agent, select a character encoding
from the list given in the <code><a href=#the-form-element>form</a></code>'s <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute
that is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>. If
none of the encodings are supported, or if none are listed, then
let the selected character encoding be UTF-8.</p>
<p>Otherwise, if the <a href="#document's-character-encoding">document's character encoding</a> is
an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>, then that is
the selected character encoding.</p>
<p>Otherwise, let the selected character encoding be UTF-8.</p>
</li>
<li><p>Let <var title="">charset</var> be the <a href=#preferred-mime-name>preferred MIME
name</a> of the selected character encoding.</li>
<li>
<p>For each entry in the <var title="">form data set</var>,
perform these substeps:</p>
<ol><li><p>If the entry's name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>"
and its type is "<code title="">hidden</code>", replace its value
with <var title="">charset</var>.</li>
<!-- the step that replaces a file with its name is missing in
this version of the algorithm -->
<li><p>For each character in the entry's name and value that
cannot be expressed using the selected character encoding,
replace the character by a string consisting of a U+0026
AMPERSAND character (&), a U+0023 NUMBER SIGN character (#),
one or more characters in the range U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9) representing the Unicode code point of the
character in base ten, and finally a U+003B SEMICOLON character
(;).</li><!-- we should say it should be the shortest
possible string, no leading zeros. this whole step is asinine,
though, so... -->
<!-- this is where the similarities with the previous section end -->
</ol></li>
<li>
<p>Encode the (now mutated) <var title="">form data set</var>
using the rules described by RFC 2388, <cite>Returning Values from
Forms: <code title="">multipart/form-data</code></cite>, and
return the resulting byte stream. <a href=#refsRFC2388>[RFC2388]</a></p>
<p>Each entry in the <var title="">form data set</var> is a
<i>field</i>, the name of the entry is the <i>field name</i> and
the value of the entry is the <i>field value</i>.</p>
<p>The order of parts must be the same as the order of fields in
the <var title="">form data set</var>. Multiple entries with the
same name must be treated as distinct fields.</p>
<p>The parts of the generated <code title="">multipart/form-data</code> resource that correspond to
non-file fields must not have a <code><a href=#content-type>Content-Type</a></code> header
specified. Their names and values must be encoded using the
character encoding selected above (field names in particular do
not get converted to a 7-bit safe encoding as suggested in RFC
<hgroup><h1>HTML5 (including next generation additions still in development)</h1>
<h2 class="no-num no-toc">Draft Standard — 11 October 2010</h2>
<h2 class="no-num no-toc">Draft Standard — 12 October 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
algorithm</dfn> is to encode the <var title="">form data set</var>
using the rules described by RFC2388, <cite>Returning Values from
Forms: <code title="">multipart/form-data</code></cite>, and return
the resulting byte stream. <a href=#refsRFC2388>[RFC2388]</a></p>
algorithm</dfn> is as follows:</p>
<p>Each entry in the <var title="">form data set</var> is a
<i>field</i>, the name of the entry is the <i>field name</i> and the
value of the entry is the <i>field value</i>, unless the entry's
name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and its type is "<code title="">hidden</code>", in which case the <i>field value</i> is the
character encoding used by the aforementioned algorithm to encode
the value of the field.</p>
<ol><!-- the first few steps of this are the same as in the previous section --><li><p>Let <var title="">result</var> be the empty string.</li>
<p>The order of parts must be the same as the order of fields in the
<var title="">form data set</var>. Multiple entries with the same
name must be treated as distinct fields.</p>
<li>
</div>
<p>If the <code><a href=#the-form-element>form</a></code> element has an <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute,
then, taking into account the characters found in the <var title="">form data set</var>'s names and values, and the character
encodings supported by the user agent, select a character encoding
from the list given in the <code><a href=#the-form-element>form</a></code>'s <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute
that is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>. If
none of the encodings are supported, or if none are listed, then
let the selected character encoding be UTF-8.</p>
<p>Otherwise, if the <a href="#document's-character-encoding">document's character encoding</a> is
an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>, then that is
the selected character encoding.</p>
<p>Otherwise, let the selected character encoding be UTF-8.</p>
</li>
<li><p>Let <var title="">charset</var> be the <a href=#preferred-mime-name>preferred MIME
name</a> of the selected character encoding.</li>
<li>
<p>For each entry in the <var title="">form data set</var>,
perform these substeps:</p>
<ol><li><p>If the entry's name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>"
and its type is "<code title="">hidden</code>", replace its value
with <var title="">charset</var>.</li>
<!-- the step that replaces a file with its name is missing in
this version of the algorithm -->
<li><p>For each character in the entry's name and value that
cannot be expressed using the selected character encoding,
replace the character by a string consisting of a U+0026
AMPERSAND character (&), a U+0023 NUMBER SIGN character (#),
one or more characters in the range U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9) representing the Unicode code point of the
character in base ten, and finally a U+003B SEMICOLON character
(;).</li><!-- we should say it should be the shortest
possible string, no leading zeros. this whole step is asinine,
though, so... -->
<!-- this is where the similarities with the previous section end -->
</ol></li>
<li>
<p>Encode the (now mutated) <var title="">form data set</var>
using the rules described by RFC 2388, <cite>Returning Values from
Forms: <code title="">multipart/form-data</code></cite>, and
return the resulting byte stream. <a href=#refsRFC2388>[RFC2388]</a></p>
<p>Each entry in the <var title="">form data set</var> is a
<i>field</i>, the name of the entry is the <i>field name</i> and
the value of the entry is the <i>field value</i>.</p>
<p>The order of parts must be the same as the order of fields in
the <var title="">form data set</var>. Multiple entries with the
same name must be treated as distinct fields.</p>
<p>The parts of the generated <code title="">multipart/form-data</code> resource that correspond to
non-file fields must not have a <code><a href=#content-type>Content-Type</a></code> header
specified. Their names and values must be encoded using the
character encoding selected above (field names in particular do
not get converted to a 7-bit safe encoding as suggested in RFC