HTML Character Sets
Distinguish a Unicode code point from the bytes used to save it.
Understand the topic
A character repertoire defines characters, while an encoding defines how those characters are represented as bytes. Unicode assigns code points across many writing systems, and UTF-8 encodes those code points. UTF-8 is compatible with ASCII for basic English letters and punctuation. Character references and encoding declarations are related to text handling but serve different roles.
Worked example
<table><caption>Text encoding concepts</caption><tr><th scope="col">Term</th><th scope="col">Meaning</th></tr><tr><td>Unicode</td><td>A standardized repertoire of characters and code points</td></tr><tr><td>UTF-8</td><td>A variable-length encoding of Unicode</td></tr><tr><td>ASCII</td><td>A small repertoire represented by values 0 to 127</td></tr><tr><td>Character reference</td><td>Markup syntax such as &copy; for a character</td></tr></table>
Saving as UTF-8 and declaring UTF-8 prevents many text-decoding problems. Language information still belongs in lang, not charset.
Practice
Distinguish a Unicode code point from the bytes used to save it.
Show a suggested answer
A code point identifies a character abstractly. An encoding such as UTF-8 maps that code point to one or more bytes.Common mistake
Do not assume every non-English character needs an HTML entity. Correctly encoded Unicode text is usually appropriate.