Emoji Sequences and Presentation Selectors
Not all emoji are single code points—many are sequences of multiple code points that rendering engines combine into a single visible glyph. Understanding emoji sequences is essential for anyone building applications that handle user-generated content, since mishandling them leads to garbled output, incorrect character counts, and broken copy-paste behaviour.
Variation Selector Sequences
Some Unicode characters have both a text (monochrome) and emoji (colourful) presentation. The presentation is controlled by a variation selector appended to the base character:
- U+FE0E VARIATION SELECTOR-15 (VS15) requests text presentation
- U+FE0F VARIATION SELECTOR-16 (VS16) requests emoji presentation
For example, U+2764 ❤ (Heavy Black Heart) followed by VS16 gives the red heart emoji ❤️. This two-code-point sequence is the "standard" form for emoji that have a text variant. Browse all emoji at the emoji browser.
Flag Emoji: Regional Indicator Sequences
Country flag emoji are represented by pairs of Regional Indicator letters (U+1F1E6–U+1F1FF). The two-letter ISO 3166-1 country code determines the flag: 🇺🇸 is U+1F1FA (Regional Indicator U) + U+1F1F8 (Regional Indicator S). This means flags don't have fixed code points—a platform constructs the flag glyph from the two-letter sequence. Unsupporting platforms show the two regional indicator letters as fallback.
Keycap Sequences
Keycap emoji like 1️⃣ are three-code-point sequences: a digit or symbol, VS16, and U+20E3 COMBINING ENCLOSING KEYCAP. They look like a single emoji character but behave as a sequence—relevant when validating input length or splitting strings.
Handling Emoji Sequences in Code
The only correct way to split emoji-containing text is by extended grapheme cluster, as defined in Unicode Standard Annex #29. Language support:
- JavaScript:
new Intl.Segmenter().segment(str) - Swift:
str.unicodeScalarsfor code points; iteratestrdirectly for grapheme clusters - Rust:
unicode-segmentationcrate'sgraphemes()method - Python:
graphemelibrary