Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions encoding.bs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ present in <a for=/>I/O queues</a> of any type and it signifies that there are n

<div algorithm>
<p>To <dfn id=concept-stream-read for="I/O queue" export>read</dfn> an <a for=list>item</a> from an
<a for=/>I/O queue</a> <var>ioQueue</var>, run these steps:
<a for=/>I/O queue</a> <var>ioQueue</var>:

<ol>
<li><p>If <var>ioQueue</var> <a for=list>is empty</a>, then wait until its <a for=list>size</a> is
Expand All @@ -143,7 +143,7 @@ present in <a for=/>I/O queues</a> of any type and it signifies that there are n

<div algorithm="I/O queue/read items">
<p>To <a for="I/O queue">read</a> a number <var>number</var> of <a for=list>items</a> from
<var>ioQueue</var>, run these steps:
<var>ioQueue</var>:

<ol>
<li><p>Let <var>readItems</var> be « ».
Expand All @@ -165,7 +165,7 @@ present in <a for=/>I/O queues</a> of any type and it signifies that there are n

<div algorithm>
<p>To <dfn for="I/O queue" export>peek</dfn> a number <var>number</var> of <a for=list>items</a>
from an <a for=/>I/O queue</a> <var>ioQueue</var>, run these steps:
from an <a for=/>I/O queue</a> <var>ioQueue</var>:

<ol>
<li><p>Wait until either <var>ioQueue</var>'s <a for=list>size</a> is equal to or greater than
Expand All @@ -175,7 +175,8 @@ from an <a for=/>I/O queue</a> <var>ioQueue</var>, run these steps:
<li><p>Let <var>prefix</var> be « ».

<li>
<p><a for=list>For each</a> <var>n</var> in <a>the range</a> 1 to <var>number</var>, inclusive:
<p><a for=list>For each</a> <var>n</var> in <a lt="the exclusive range">the range</a> 0 to
<var>number</var>, exclusive:

<ol>
<li><p>If <var>ioQueue</var>[<var>n</var>] is <a>end-of-queue</a>, <a for=iteration>break</a>.
Expand All @@ -190,7 +191,7 @@ from an <a for=/>I/O queue</a> <var>ioQueue</var>, run these steps:

<div algorithm>
<p>To <dfn id=concept-stream-push for="I/O queue" export>push</dfn> an <a for=list>item</a>
<var>item</var> to an <a for=/>I/O queue</a> <var>ioQueue</var>, run these steps:
<var>item</var> to an <a for=/>I/O queue</a> <var>ioQueue</var>:

<ol>
<li>
Expand Down Expand Up @@ -234,7 +235,7 @@ items, in the given order, before the first item in the queue.

<div algorithm>
<p>To <dfn for="to I/O queue">convert</dfn> a <a for=/>list</a>, <a>string</a>, or
<a>byte sequence</a> <var>input</var> into an <a for=/>I/O queue</a>, run these steps:
<a>byte sequence</a> <var>input</var> into an <a for=/>I/O queue</a>:

<ol>
<li><p><a for=/>Assert</a>: <var>input</var> is not a <a for=/>list</a> or it does not
Expand Down Expand Up @@ -426,7 +427,7 @@ as "<code>utf-8</code>".
<div algorithm>
<p>To
<dfn export lt="get an encoding|getting an encoding" id=concept-encoding-get>get an encoding</dfn>
from a string <var>label</var>, run these steps:
from a string <var>label</var>:

<ol>
<li><p>Remove any leading and trailing <a>ASCII whitespace</a> from
Expand Down Expand Up @@ -816,7 +817,7 @@ plans to remove these.</p>
<h3 id=output-encodings>Output encodings</h3>

<p>To <dfn export>get an output encoding</dfn> from an <a for=/>encoding</a>
<var>encoding</var>, run these steps:
<var>encoding</var>:

<ol>
<li><p>If <var>encoding</var> is <a>replacement</a> or <a>UTF-16BE/LE</a>, then return
Expand Down Expand Up @@ -1081,7 +1082,7 @@ different format here, to be able to represent ranges.)

<div algorithm>
<p>To <dfn export>UTF-8 decode</dfn> an I/O queue of bytes <var>ioQueue</var> given an optional I/O
queue of scalar values <var>output</var> (default « »), run these steps:
queue of scalar values <var>output</var> (default « »):

<ol>
<li><p>Let <var>buffer</var> be the result of <a for="I/O queue">peeking</a> three bytes from
Expand All @@ -1099,7 +1100,7 @@ queue of scalar values <var>output</var> (default « »), run these steps:

<div algorithm>
<p>To <dfn export>UTF-8 decode without BOM</dfn> an I/O queue of bytes <var>ioQueue</var> given an
optional I/O queue of scalar values <var>output</var> (default « »), run these steps:
optional I/O queue of scalar values <var>output</var> (default « »):

<ol>
<li><p><a>Process a queue</a> with an instance of <a>UTF-8</a>'s <a for=/>decoder</a>,
Expand All @@ -1111,7 +1112,7 @@ optional I/O queue of scalar values <var>output</var> (default « »), run these

<div algorithm>
<p>To <dfn export>UTF-8 decode without BOM or fail</dfn> an I/O queue of bytes <var>ioQueue</var>
given an optional I/O queue of scalar values <var>output</var> (default « »), run these steps:
given an optional I/O queue of scalar values <var>output</var> (default « »):
<!-- Needed by https://tools.ietf.org/html/rfc6455#section-8.1 and
https://webassembly.github.io/spec/js-api/#dom-module-customsections-moduleobject-sectionname
-->
Expand Down Expand Up @@ -1152,8 +1153,7 @@ optional I/O queue of bytes <var>output</var> (default « »), return the result

<div algorithm>
<p>To <dfn export>decode</dfn> an I/O queue of bytes <var>ioQueue</var> given a fallback encoding
<var>encoding</var> and an optional I/O queue of scalar values <var>output</var> (default « »), run
these steps:
<var>encoding</var> and an optional I/O queue of scalar values <var>output</var> (default « »):

<ol>
<li><p>Let <var>BOMEncoding</var> be the result of <a>BOM sniffing</a> <var>ioQueue</var>.
Expand All @@ -1180,7 +1180,7 @@ these steps:
</div>

<div algorithm>
<p>To <dfn export>BOM sniff</dfn> an I/O queue of bytes <var>ioQueue</var>, run these steps:
<p>To <dfn export>BOM sniff</dfn> an I/O queue of bytes <var>ioQueue</var>:

<ol>
<li><p>Let <var>BOM</var> be the result of <a for="I/O queue">peeking</a> 3 bytes from
Expand Down Expand Up @@ -1210,8 +1210,7 @@ corresponding to the byte order mark found, or null otherwise.

<div algorithm>
<p>To <dfn export>encode</dfn> an I/O queue of scalar values <var>ioQueue</var> given an encoding
<var>encoding</var> and an optional I/O queue of bytes <var>output</var> (default « »), run these
steps:
<var>encoding</var> and an optional I/O queue of bytes <var>output</var> (default « »):

<ol>
<li><p>Let <var>encoder</var> be the result of <a>getting an encoder</a> from <var>encoding</var>.
Expand Down Expand Up @@ -1241,8 +1240,7 @@ is safe as it never triggers <a>errors</a>. [[HTML]]

<div algorithm>
<p>To <dfn export>encode or fail</dfn> an I/O queue of scalar values <var>ioQueue</var> given an
<a for=/>encoder</a> instance <var>encoder</var> and an I/O queue of bytes <var>output</var>, run
these steps:
<a for=/>encoder</a> instance <var>encoder</var> and an I/O queue of bytes <var>output</var>:

<ol>
<li><p>Let <var>potentialError</var> be the result of <a>processing a queue</a> with
Expand Down Expand Up @@ -1863,7 +1861,7 @@ constructor steps are:
<p>To <dfn export>set up a text decoder stream</dfn> given a {{TextDecoderStream}} object
<var>stream</var>, an optional [=/encoding=] <var>encoding</var> (default <a>UTF-8</a>), an optional
<a for=/>error mode</a> <var>errorMode</var> (default "<code>replacement</code>"), and an optional
boolean <var>ignoreBOM</var> (default false), run these steps:
boolean <var>ignoreBOM</var> (default false):

<ol>
<li><p><a>Assert</a>: <var>encoding</var> is not <a>replacement</a>.
Expand Down