Skip to content

Commit 75b2415

Browse files
committed
Editorial: make ISO-2022-JP encoder perform error state switch
This way you can invoke its handler directly without going the process algorithm as is needed to fix #235. This also avoids the need for "prepend" in the "process" algorithm. Additionally, this commit adds two clarifying asserts to the "process" algorithm documenting what error modes can be in effect when.
1 parent 92569b5 commit 75b2415

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

encoding.bs

+20-5
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ happening.
303303
<var>encoderDecoderInstance</var> is a <a for=/>decoder</a> instance, otherwise
304304
"<code>fatal</code>".
305305

306+
<li><p>Assert: if <var>encoderDecoderInstance</var> is an <a for=/>encoder</a> instance,
307+
<var>mode</var> is not "<code>replacement</code>".
308+
309+
<li><p>Assert: if <var>encoderDecoderInstance</var> is a <a for=/>decoder</a> instance,
310+
<var>mode</var> is not "<code>html</code>".
311+
306312
<li><p>Assert: if <var>encoderDecoderInstance</var> is an <a for=/>encoder</a> instance,
307313
<var>item</var> is not a <a>surrogate</a>.
308314

@@ -340,9 +346,9 @@ happening.
340346
<dd><a>Push</a> U+FFFD to <var>output</var>.
341347

342348
<dt>"<code>html</code>"
343-
<dd><a>Prepend</a> U+0026, U+0023, followed by the
344-
shortest sequence of <a>ASCII digits</a> representing <var>result</var>'s
345-
<a>code point</a> in base ten, followed by U+003B to <var>input</var>.
349+
<dd><a>Push</a> the result of <a>UTF-8 encoding</a> U+0026 (&amp;), U+0023 (#), followed by the
350+
shortest sequence of <a>ASCII digits</a> representing <var>result</var>'s <a>code point</a> in
351+
base ten, followed by U+003B (;) to <var>output</var>.
346352
<!-- &# ... ; -->
347353

348354
<dt>"<code>fatal</code>"
@@ -2938,8 +2944,17 @@ and <var>code point</var>, runs these steps:
29382944
<p class=note>If <var>pointer</var> is non-null, it is less than 8836 due to the nature of
29392945
<a>index jis0208</a> and the <a>index pointer</a> operation.
29402946

2941-
<li><p>If <var>pointer</var> is null, return <a>error</a> with
2942-
<var>code point</var>.
2947+
<li>
2948+
<p>If <var>pointer</var> is null, then:
2949+
2950+
<ol>
2951+
<li><p>If <a>ISO-2022-JP encoder state</a> is <a lt="ISO-2022-JP encoder jis0208">jis0208</a>,
2952+
then <a>prepend</a> <var>code point</var> to <var>ioQueue</var>, set
2953+
<a>ISO-2022-JP encoder state</a> to <a lt="ISO-2022-JP encoder ASCII">ASCII</a>, and return three
2954+
bytes 0x1B 0x28 0x42.
2955+
2956+
<li><p>Return <a>error</a> with <var>code point</var>.
2957+
</ol>
29432958

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

0 commit comments

Comments
 (0)