Inspect combined Unicode letters and grapheme boundaries

How combined Unicode letters work, why grapheme boundaries matter when reversing or styling text, and when plain text is the safer choice.

Many letters that look like one character are stored as several. An accented letter can be a base letter followed by a combining accent. A family emoji can be several people joined by invisible connectors. A flag can be two special letters. Tools that reverse, mirror or restyle text work on this stored data, not on what you see. If a tool ignores how characters combine, it can detach accents, split emoji and produce output that looks broken or means something else. This review explains how to inspect combined letters, what grapheme boundaries are, and how to judge whether a transformation keeps text readable and usable.

Is grapheme-aware inspection right for your use?

A grapheme-aware inspector or transformer is worth using whenever text may contain accents, non-Latin scripts, emoji or decorative combining marks, and you plan to reverse it, count it, truncate it or substitute characters. Its main benefit is that it treats each user-perceived character as a single unit, so accents stay on their letters and emoji sequences stay whole.

The key tradeoff is that grapheme boundaries come from rules defined by the Unicode Standard, and those rules are a general approximation rather than a guarantee for every language. They have been revised across Unicode versions, including changes affecting some Indic conjuncts. Two tools built on different Unicode versions can segment the same string differently. Inspection tells you what a string contains. It does not promise that every app, font or screen reader will display or announce it the same way.

Use plain, unmodified text for names, addresses, identifiers, passwords, legal or medical wording, anything people need to search for, and anything that must work with assistive technology. Reversed, mirrored or styled output suits decoration, puzzles and short display text, with a plain version available nearby.

What a combined letter actually is

Unicode assigns numbers, called code points, to characters. Some visible characters have more than one valid encoding. The letter é can be stored as one precomposed code point, U+00E9. It can also be stored as two code points: U+0065 (e) followed by U+0301 (combining acute accent). Both forms display the same and Unicode treats them as canonically equivalent, but the stored data differs.

Unicode Standard Annex #29 defines extended grapheme clusters: sequences of code points that should be treated as one user-perceived character for tasks such as cursor movement, deletion and selection. Common multi-code-point clusters include:

  • A base letter plus one or more combining marks, such as e + combining acute accent
  • Emoji joined with the zero-width joiner (U+200D), such as family or profession emoji
  • Emoji with skin-tone modifiers or variation selectors
  • Flags built from two regional indicator symbols
  • Hangul syllables built from separate jamo
  • Stacks of many combining marks, as in so-called glitch or Zalgo text

How to inspect a string

An inspector should show three things for each visible character: the grapheme cluster, the code points inside it, and their Unicode names. Byte or code-unit counts help when you deal with length limits. The following Python snippet lists code points and names using only the standard library:

import unicodedata

s = "e\u0301"
for ch in s:
    print(f"U+{ord(ch):04X} {unicodedata.name(ch)}")

# U+0065 LATIN SMALL LETTER E
# U+0301 COMBINING ACUTE ACCENT

The Python standard library does not provide grapheme segmentation, so you need a third-party package for that. In JavaScript, Intl.Segmenter with grapheme granularity splits text into clusters according to the Unicode rules built into the engine:

const seg = new Intl.Segmenter("en", { granularity: "grapheme" });
const clusters = [...seg.segment(text)].map(s => s.segment);
console.log(clusters.length); // user-perceived characters

The same visible character can have very different lengths depending on what you count. The figures below follow from how each sequence is encoded:

Text | Grapheme clusters | Code points | UTF-16 code units | UTF-8 bytes
é (precomposed U+00E9) | 1 | 1 | 1 | 2
é (e + U+0301) | 1 | 2 | 2 | 3
US flag (U+1F1FA U+1F1F8) | 1 | 2 | 4 | 8
Family emoji (man ZWJ woman ZWJ girl) | 1 | 5 | 8 | 18

Whenever a destination enforces a character limit, ask which of these units it counts. A limit measured in code points or UTF-16 units will count a combined letter or emoji as several characters.

What reversal, mirroring and styling actually change

Tools use the words reverse, mirror and font loosely, but each one describes a different operation:

  • Character reversal changes the stored order of characters. It is safe only if the tool reverses grapheme clusters rather than code points or code units.
  • Word reversal reorders whole words and leaves each word intact. Combined letters are not affected unless the tool also reverses within words.
  • Mirrored or upside-down text replaces characters with different Unicode characters that look flipped. The stored text changes, and many letters have no true mirrored counterpart.
  • Unicode fonts swap ordinary letters for characters such as mathematical bold or script letters. They are not fonts in the typographic sense. The underlying characters are different.
  • CSS transforms or font styling change only how text is displayed. The stored text stays the same, so copying it usually yields the original characters.
  • Bidirectional display is how right-to-left scripts such as Arabic and Hebrew are laid out. It is a rendering process. Reversing stored characters to imitate it produces incorrect text for those scripts.

The following example shows why reversal needs to respect grapheme boundaries. It uses café with a decomposed é:

Input code points:      c  a  f  e  U+0301
Code-point reversal:    U+0301  e  f  a  c   -> accent has no base, or lands on a preceding character
Grapheme reversal:      [e U+0301]  f  a  c  -> éfac

Emoji follow the same principle. Reversing the code points of the family emoji man–ZWJ–woman–ZWJ–girl produces girl–ZWJ–woman–ZWJ–man. That is not a standard sequence, so it typically appears as three separate emoji. Reversing the two regional indicators of the US flag (U and S) yields S then U, which is not a recommended flag sequence and will usually show as two letter symbols. Reversing UTF-16 code units, which some simple string functions do, can split a single emoji into invalid halves. A grapheme-aware tool keeps each of these sequences together.

Normalization can also change stored data silently. Converting to NFC merges e + U+0301 into U+00E9. NFD does the reverse. The compatibility forms, NFKC and NFKD, go further: they can convert styled mathematical letters back to plain letters. When you inspect a string before and after a transformation, check whether the tool normalized it, because that changes the code points even if nothing looks different.

Will the result stay readable after copying or sharing?

Copying usually transfers the code points themselves, so whatever a tool stored is what lands in the destination. That has several practical effects:

  • Display: whether a combined letter or emoji sequence renders correctly depends on the fonts and text engine at the destination. An unsupported sequence may show as separate pieces or as empty boxes.
  • Search: the precomposed and decomposed forms of a letter are byte-different. A search that does not normalize text may fail to match one form against the other. Substituted styled letters generally will not match ordinary words at all.
  • Editing: in environments that segment text correctly, the cursor and backspace treat a cluster as one unit. Elsewhere, users may delete an accent separately from its letter or break an emoji sequence partway through.
  • Assistive technology: screen readers announce the characters they receive. Substituted, mirrored or heavily stacked characters may be read as symbol names, read letter by letter, or skipped, depending on the reader and its settings.
  • Reading order: reversed text is stored in reversed order, so anything that reads the underlying text will encounter it backwards, whatever it looks like.

Evidence gap: no documentation or scoped tests were available for specific apps, social platforms, browsers or screen readers. This article cannot confirm how any named destination displays, counts, searches or announces combined or transformed text. One successful rendering on one device does not show that others will behave the same. Test in the exact destination and assistive technology you care about before relying on transformed text.

Provide a plain-text equivalent whenever the content carries meaning someone must understand, find or act on. Examples include usernames people need to type, captions, alt text, announcements and anything screen-reader users must be able to read. Keep the plain version as the primary text and use transformed text only as decoration next to it.

A short checklist for judging a tool

  • Paste a test string that includes a decomposed accented letter, a ZWJ emoji, a flag and a skin-tone emoji, then confirm each one survives as a single unit.
  • Compare code points before and after the transformation to see whether the tool normalized the text or substituted characters.
  • Check which length the tool reports: grapheme clusters, code points or code units.
  • Find out whether the tool changes stored characters or only changes how text is displayed.
  • Test the output in your actual destination and with the assistive technology your readers use.
  • Keep a plain-text version for anything people need to read, search or act on.