What if a piece is missing or has the wrong label?
03A careful reader checks the whole item before treating its bytes as a character.
Do not guess a character from only the bits you hoped to see.
Incoming pieces
Each piece is eight bits: 1 = on, 0 = off. Read the pieces in this order.
What happens if you change this?
Make one change, then watch again. Restart restores the original example.
Slash is represented by the single byte 2F.
Key idea: A partial valid beginning can wait. A forbidden encoding must not be accepted as valid text.
Terms
- UTF-8
- A rule for turning Unicode character numbers into ordered bytes, and back.
- Code point
- A character number in Unicode. A scalar value excludes reserved surrogate numbers.
- Byte / bit
- A byte is eight bits. A bit has one of two values: zero or one.
- Leading / continuation byte
- The first piece tells the reader how many bytes belong together. Following pieces start with the bits 10.
- Normalization
- A specified way to transform Unicode text before comparison. It does not turn every lookalike into the same letter.
- BOM
- A contextual initial encoding signature. UTF-8 never uses it to switch byte order.
Rules & examples
A partial valid beginning can wait. A forbidden encoding must not be accepted as valid text.
- Do not decode invalid sequences or surrogate values as valid characters.
- UTF-8 does not encode values above U+10FFFF.
- Overlong sequences can create security failures when filters and decoders disagree.
Examples are illustrative. Consult the linked RFC and its errata for implementation details.
RFC 3629 §§3–4,10. Bytes E2 82. Keep the partial item and wait for more bytes. Streaming wait is a teaching reader state, not permission to accept truncated final input. Overlong forms, surrogates, values above U+10FFFF and five/six-byte forms are not UTF-8. Recovery/replacement policy belongs to the application.
Sources
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Start with this guide; no earlier guide is needed for the overview.
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.