Skip to content

[spec] Add missing UTF-8 side condition - #928

Merged
rossberg merged 2 commits into
masterfrom
utf8-2
Dec 6, 2018
Merged

rossberg merged 2 commits into
masterfrom
utf8-2

Conversation

@rossberg

@rossberg rossberg commented Dec 6, 2018

Copy link
Copy Markdown
Member

Continuation bytes must not have bot 6 set.

@littledan

Copy link
Copy Markdown
Collaborator

Any way you could reference the WHATWG encoding spec or the UTF-8 spec instead of having your own here?

@rossberg

rossberg commented Dec 6, 2018

Copy link
Copy Markdown
Member Author

It already refers to the Unicode spec, I added a section reference. Unfortunately, Unicode does not provide any named definition that would be directly usable here.

\wedge & c = 2^{18}(b_1-\hex{F0})+2^{12}(b_2-\hex{80})+2^6(b_3-\hex{80})+(b_4-\hex{80})) \\
\end{array} \\
\end{array} \\
\where b_2, b_3, b_4 < \hex{C0} \\

@xtuc xtuc Dec 6, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the upper boundary be based on the number of byte needed? As in the WHATWG spec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, all continuation bytes use the full lower 6 bits for payload while the high two bits must be the tag 10 (which is what the side condition ensures). The WHATWG spec obscures this by giving an imperative algorithm with ad-hoc optimisations instead of a declarative spec.

@rossberg
rossberg merged commit 89ae39c into master Dec 6, 2018
@rossberg
rossberg deleted the utf8-2 branch December 6, 2018 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants