Skip to content

gb18030 decoder: unwind from fourth byte when it's not a digit #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2017
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
27 changes: 13 additions & 14 deletions encoding.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,25 +1625,24 @@ consumers of content generated with <a>GBK</a>'s <a for=/>encoder</a>.
<p>If <a>gb18030 third</a> is not 0x00, then:

<ol>
<li><p>Let <var>code point</var> be null.
<li>
<p>If <var>byte</var> is not in the range 0x30 to 0x39, inclusive, then:

<li><p>If <var>byte</var> is in the range 0x30 to 0x39, inclusive, set
<var>code point</var> to the
<a>index gb18030 ranges code point</a> for
<ol>
<li><p><a>Prepend</a> <a>gb18030 second</a>, <a>gb18030 third</a>, and <var>byte</var> to
<var>stream</var>.

<li><p>Set <a>gb18030 first</a>, <a>gb18030 second</a>, and <a>gb18030 third</a> to 0x00.

<li><p>Return <a>error</a>.
</ol>

<li><p>Let <var>code point</var> be the <a>index gb18030 ranges code point</a> for
((<a>gb18030 first</a> &minus; 0x81) × (10 × 126 × 10)) +
((<a>gb18030 second</a> &minus; 0x30) × (10 × 126)) +
((<a>gb18030 third</a> &minus; 0x81) × 10) + <var>byte</var> &minus; 0x30.

<li><p>Let <var>buffer</var> be a byte sequence consisting of
<a>gb18030 second</a>, <a>gb18030 third</a>, and <var>byte</var>, in
order.

<li><p>Set <a>gb18030 first</a>, <a>gb18030 second</a>, and
<a>gb18030 third</a> to 0x00.

<li><p>If <var>code point</var> is null,
<a>prepend</a> <var>buffer</var> to
<var>stream</var> and return <a>error</a>.
<li><p>If <var>code point</var> is null, return <a>error</a>.

<li><p>Return a code point whose value is <var>code point</var>.
</ol>
Expand Down