Skip to content

Commit

Permalink
Editorial: make ISO-2022-JP encoder perform error state switch
Browse files Browse the repository at this point in the history
This avoids the need for "prepend" in the "process" algorithm as is needed to fix #235. 

Additionally, this commit adds two clarifying asserts to the "process" algorithm documenting what error modes can be in effect when.

Related tests: web-platform-tests/wpt#26158.
  • Loading branch information
annevk authored Oct 21, 2020
1 parent 92569b5 commit a5e3e11
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions encoding.bs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ happening.
<var>encoderDecoderInstance</var> is a <a for=/>decoder</a> instance, otherwise
"<code>fatal</code>".

<li><p>Assert: if <var>encoderDecoderInstance</var> is an <a for=/>encoder</a> instance,
<var>mode</var> is not "<code>replacement</code>".

<li><p>Assert: if <var>encoderDecoderInstance</var> is a <a for=/>decoder</a> instance,
<var>mode</var> is not "<code>html</code>".

<li><p>Assert: if <var>encoderDecoderInstance</var> is an <a for=/>encoder</a> instance,
<var>item</var> is not a <a>surrogate</a>.

Expand Down Expand Up @@ -340,10 +346,9 @@ happening.
<dd><a>Push</a> U+FFFD to <var>output</var>.

<dt>"<code>html</code>"
<dd><a>Prepend</a> U+0026, U+0023, followed by the
shortest sequence of <a>ASCII digits</a> representing <var>result</var>'s
<a>code point</a> in base ten, followed by U+003B to <var>input</var>.
<!-- &# ... ; -->
<dd><a>Push</a> 0x26 (&amp;), 0x23 (#), followed by the shortest sequence of 0x30 (0) to
0x39 (9), inclusive, representing <var>result</var>'s <a>code point</a>'s
<a for="code point">value</a> in base ten, followed by 0x3B (;) to <var>output</var>.

<dt>"<code>fatal</code>"
<dd>Return <a>error</a>.
Expand Down Expand Up @@ -2938,8 +2943,17 @@ and <var>code point</var>, runs these steps:
<p class=note>If <var>pointer</var> is non-null, it is less than 8836 due to the nature of
<a>index jis0208</a> and the <a>index pointer</a> operation.

<li><p>If <var>pointer</var> is null, return <a>error</a> with
<var>code point</var>.
<li>
<p>If <var>pointer</var> is null, then:

<ol>
<li><p>If <a>ISO-2022-JP encoder state</a> is <a lt="ISO-2022-JP encoder jis0208">jis0208</a>,
then <a>prepend</a> <var>code point</var> to <var>ioQueue</var>, set
<a>ISO-2022-JP encoder state</a> to <a lt="ISO-2022-JP encoder ASCII">ASCII</a>, and return three
bytes 0x1B 0x28 0x42.

<li><p>Return <a>error</a> with <var>code point</var>.
</ol>

<li><p>If <a>ISO-2022-JP encoder state</a> is not
<a lt="ISO-2022-JP encoder jis0208">jis0208</a>,
Expand Down

0 comments on commit a5e3e11

Please sign in to comment.