Skip to content

Commit

Permalink
Use Encoding's "UTF-8 encode" hook.
Browse files Browse the repository at this point in the history
This is nicer than referencing the utf-8 encoding directly.
This fixes #37
  • Loading branch information
mkruisselbrink committed Feb 4, 2017
1 parent b21072a commit 64c346d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ user agents must run the following steps:
1. Let |element| be the |i|th element of |a|.
2. If |element| is a {{USVString}}, run the following substeps:

1. Encode |s| as <a>utf-8</a> and append the resulting bytes to |bytes|.
1. Append the result of [=UTF-8 encoding=] |s| to |bytes|.

Note: The algorithm from WebIDL [[WebIDL]] replaces unmatched surrogates in an invalid utf-16 string
with U+FFFD replacement characters.
Expand Down Expand Up @@ -567,7 +567,7 @@ user agents must run the following steps:

1. Let |element| be the |i|'th element of |a|.
2. If |element| is a {{USVString}}, run the following substeps:
1. Encode |s| as <a>utf-8</a> and append the resulting <a>byte</a> to |bytes|.
1. Append the result of [=UTF-8 encoding=] |s| to |bytes|.

Note: The algorithm from WebIDL [[WebIDL]] replaces unmatched surrogates in an invalid utf-16 string with U+FFFD replacement characters.
Scenarios exist when the {{Blob}} constructor may result in some data loss due to lost or scrambled character sequences.
Expand Down Expand Up @@ -1235,7 +1235,7 @@ the following <dfn id="encoding-determination">encoding determination</dfn> step

<div class="example">
If <code>blob</code> has a {{Blob/type}} attribute of <code>text/plain;charset=utf-8</code>
then <a>getting an encoding</a> is run using <a>utf-8</a> as the label.
then <a>getting an encoding</a> is run using <code>"utf-8"</code> as the label.
Note that user agents must parse and extract the portion of the Charset Parameter that constitutes a <i>label</i> of an encoding.
</div>
5. If the <a>getting an encoding</a> steps above return failure,
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">File API</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-02-03">3 February 2017</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-02-04">4 February 2017</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
Expand Down Expand Up @@ -1806,7 +1806,7 @@ <h3 class="heading settled" data-level="3.1" id="constructorBlob"><span class="s
<p>If <var>element</var> is a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></code>, run the following substeps:</p>
<ol>
<li data-md="">
<p>Encode <var>s</var> as <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8">utf-8</a> and append the resulting bytes to <var>bytes</var>.</p>
<p>Append the result of <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode">UTF-8 encoding</a> <var>s</var> to <var>bytes</var>.</p>
<p class="note" role="note"><span>Note:</span> The algorithm from WebIDL <a data-link-type="biblio" href="#biblio-webidl">[WebIDL]</a> replaces unmatched surrogates in an invalid utf-16 string
with U+FFFD replacement characters.
Scenarios exist when the <code class="idl"><a data-link-type="idl" href="#dfn-Blob" id="ref-for-dfn-Blob-13">Blob</a></code> constructor may result in some data loss
Expand Down Expand Up @@ -2079,7 +2079,7 @@ <h3 class="heading settled" data-level="4.1" id="file-constructor"><span class="
<p>If <var>element</var> is a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></code>, run the following substeps:</p>
<ol>
<li data-md="">
<p>Encode <var>s</var> as <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8">utf-8</a> and append the resulting <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#byte">byte</a> to <var>bytes</var>.</p>
<p>Append the result of <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode">UTF-8 encoding</a> <var>s</var> to <var>bytes</var>.</p>
</ol>
<p class="note" role="note"><span>Note:</span> The algorithm from WebIDL <a data-link-type="biblio" href="#biblio-webidl">[WebIDL]</a> replaces unmatched surrogates in an invalid utf-16 string with U+FFFD replacement characters.
Scenarios exist when the <code class="idl"><a data-link-type="idl" href="#dfn-Blob" id="ref-for-dfn-Blob-38">Blob</a></code> constructor may result in some data loss due to lost or scrambled character sequences.</p>
Expand Down Expand Up @@ -2710,7 +2710,7 @@ <h3 class="heading settled" data-level="6.4" id="enctype"><span class="secno">6.
and the <code class="idl"><a data-link-type="idl" href="#dfn-fileBlob" id="ref-for-dfn-fileBlob-5">blob</a></code> argument’s <code class="idl"><a data-link-type="idl" href="#dfn-type" id="ref-for-dfn-type-18">type</a></code> attribute is present,
and it uses a Charset Parameter <a data-link-type="biblio" href="#biblio-rfc2046">[RFC2046]</a>,
set <var>encoding</var> to the result of <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#concept-encoding-get">getting an encoding</a> for the portion of the Charset Parameter that is a <i>label</i> of an encoding.</p>
<div class="example" id="example-21540bcb"><a class="self-link" href="#example-21540bcb"></a> If <code>blob</code> has a <code class="idl"><a data-link-type="idl" href="#dfn-type" id="ref-for-dfn-type-19">type</a></code> attribute of <code>text/plain;charset=utf-8</code> then <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#concept-encoding-get">getting an encoding</a> is run using <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8">utf-8</a> as the label.
<div class="example" id="example-e6bec91d"><a class="self-link" href="#example-e6bec91d"></a> If <code>blob</code> has a <code class="idl"><a data-link-type="idl" href="#dfn-type" id="ref-for-dfn-type-19">type</a></code> attribute of <code>text/plain;charset=utf-8</code> then <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#concept-encoding-get">getting an encoding</a> is run using <code>"utf-8"</code> as the label.
Note that user agents must parse and extract the portion of the Charset Parameter that constitutes a <i>label</i> of an encoding. </div>
<li data-md="">
<p>If the <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#concept-encoding-get">getting an encoding</a> steps above return failure,
Expand Down Expand Up @@ -3670,7 +3670,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
<ul>
<li><a href="https://encoding.spec.whatwg.org/#decode">decode</a>
<li><a href="https://encoding.spec.whatwg.org/#concept-encoding-get">getting an encoding</a>
<li><a href="https://encoding.spec.whatwg.org/#utf-8">utf-8</a>
<li><a href="https://encoding.spec.whatwg.org/#utf-8-encode">utf-8 encode</a>
</ul>
<li>
<a data-link-type="biblio">[Fetch]</a> defines the following terms:
Expand Down

0 comments on commit 64c346d

Please sign in to comment.