Grapheme cluster
A grapheme cluster is a Unicode text segment delimited by specified boundary rules to approximate a user-perceived character.
Variant: Default extended grapheme clusters follow UAX #29 boundary rules; legacy and tailored clusters are distinct alternatives. State the Unicode version and any tailoring when recording a count. A cluster can contain several scalar values, and a rendered glyph can span more than one cluster. [1]
Counting: U+0065 U+0301 is one extended cluster, two scalar values, two UTF-16 units and three UTF-8 bytes. U+1F1F5 U+1F1F1 is one extended cluster but eight UTF-8 bytes. Segmenting text does not normalize its spelling or determine a filesystem's name-equality policy. [1] [2]
Storage: A cluster limit is not a byte quota: repeated combining marks can extend one cluster. Truncating at a scalar boundary can still split a cluster. A display label may be shortened at an appropriate cluster boundary, but a recovery identifier needs its original representation or an explicit reversible mapping. [1] [3]
Chunking: Boundary decisions need context. For three regional indicators split after the first, separate segmentation yields (first) (second third), but whole-text segmentation yields (first second) (third). Both have two clusters, so count equality alone does not validate boundaries. The linked probe records both partitions without changing the scalar sequence; it is not a streaming segmenter. [1] [3]
Relations
Limitations
- Default boundaries approximate user expectations; script, language and application requirements can need tailoring.
Citations
- Unicode Standard Annex 29 revision 47: grapheme cluster boundaries
- RFC 3629: UTF-8 validity and malformed input
- Hesela: text length units in filename recovery
Sources & caveats
- UAX #29 revision 47 supplies the reference rules. The linked bounded examples record Node, ICU and Unicode versions; they are not a complete segmentation-conformance test.