Why one visible character may contain several code points
Unicode assigns identifiers called code points to characters and related text elements. A visible character can sometimes be represented by several code points, such as a letter followed by a combining accent. This is why counting stored text elements is not always the same as counting the characters a reader sees.
Go deeper
Text has more than one layer
Unicode provides a shared system for representing writing from many languages. A code point is an assigned numerical position in that system.
Some visible characters correspond to one code point. Others are built from several, such as a base letter plus a combining mark. A user-perceived character can therefore be a grapheme cluster rather than a single code point.
UTF-8 is an encoding that converts Unicode code points into bytes. These are different layers: code points identify text elements, while bytes store their encoded representation.
- Bytes are storage units.
- Code points identify encoded text elements.
- Grapheme clusters often correspond to what readers treat as one character.
A text editor that deletes one byte or code point at a time without considering these distinctions can handle some writing incorrectly.