Find Unicode Characters in Text

How to find and identify the Unicode characters in a piece of text, including hidden, look-alike and styled characters, and why it matters after a transformation.

Text that looks ordinary can contain characters you cannot see or easily tell apart: zero-width spaces, direction controls, letters from another script that look like Latin letters, or "fancy font" letters that are really mathematical symbols. Finding these characters means breaking the text into code points and reading each code point's number and name. This article explains what that inspection shows, how to do it, and how to use it to judge whether a reverse, mirror or styling transformation kept the text usable.

Is code point inspection the right check for your purpose?

Use a code point inspector to confirm what is actually stored in the text. That is the only reliable way to tell a real letter from a look-alike, to find invisible characters, and to see whether a transformation changed the characters or only their appearance. Its main limit is that it shows characters but not how they look. It cannot tell you how a given app, font or screen reader will display or read the text. To answer that, you also need to test in the place where the text will be used.

Inspection is most useful in these situations: text pasted from the web or a document behaves oddly; a search, comparison or password check fails on text that looks correct; you are checking styled or reversed output before publishing it; or you suspect a homoglyph or direction-control trick. If the text only needs to be read and searched normally, you usually do not need styled or transformed text. Plain text that passes inspection with no surprises is the safer choice.

What an inspector reveals

Every character in Unicode has a code point, written as U+ followed by a hexadecimal number, and most have a formal name. An inspector lists these values for each position in the string. Two strings that look identical on screen can produce different lists, and the difference is usually the cause of the problem you are investigating.

Character | Code point and name | Why it matters
(invisible) | U+200B ZERO WIDTH SPACE | Splits words for search and matching while showing no gap
(invisible) | U+200D ZERO WIDTH JOINER | Joins emoji into combined sequences; stray copies break comparisons
(invisible) | U+FEFF ZERO WIDTH NO-BREAK SPACE | Often a leftover byte order mark at the start of a file or field
(looks like a space) | U+00A0 NO-BREAK SPACE | Looks like a normal space but is not U+0020, so exact matches fail
(invisible) | U+202E RIGHT-TO-LEFT OVERRIDE | Changes display order without changing stored order
а | U+0430 CYRILLIC SMALL LETTER A | Looks like Latin a (U+0061) in many fonts
𝐀 | U+1D400 MATHEMATICAL BOLD CAPITAL A | A separate symbol, not a bold A; used by many "font" generators
◌́ | U+0301 COMBINING ACUTE ACCENT | Attaches to the preceding letter; one visible letter, two code points

What transformations actually change

Words like "reverse", "mirror" and "font" cover several different mechanisms. An inspector shows which one you are dealing with, because some change the stored characters and others only change how they are displayed.

  • Character or word reversal changes the stored order of characters or words. The inspector shows the code points in a new sequence.
  • Upside-down or mirrored-glyph text replaces letters with different characters that look rotated or flipped, often from other scripts or symbol blocks. The inspector shows entirely different code points.
  • "Font" or styled-letter generators replace letters with characters from blocks such as Mathematical Alphanumeric Symbols. No font changes. The text is now made of symbols.
  • CSS presentation, such as a horizontal flip transform or a font-family change, affects only how a page displays the text. The underlying characters stay the same, and copying usually gives you the original text.
  • Bidirectional display uses direction controls such as U+202E, or the isolates U+2066 to U+2069, to change visual order. The stored order stays the same, and the inspector shows the control characters themselves.

Reversal output is a useful thing to inspect. A naive reversal works one code point at a time, which breaks anything made of several code points. In "café", if the é is stored as e followed by U+0301, reversing the code points moves the accent ahead of the e, so it attaches to whatever character comes next. An emoji such as a family made of person emoji joined with U+200D splits into its parts or recombines in the wrong order. A flag is a pair of regional indicator symbols, so reversing Canada's pair (C, A) gives the pair for Ascension Island (A, C). A careful reversal works on grapheme clusters, the units a reader sees as single characters. Comparing the code point lists before and after shows which kind of reversal you got.

Will the result stay readable and usable after copying?

Character substitutions survive copy and paste because they are the text. The same property causes most of the practical problems.

  • Search and matching: A search for "bold" will not match text written in mathematical bold letters, and a zero-width space inside a word stops it from matching. Systems that apply NFKC compatibility normalization map many styled letters back to plain ones, but you cannot assume a given destination does this.
  • Assistive technology: Screen readers may read substituted symbols by their character names, spell them out, or skip them. Results differ between screen readers, versions and settings. This article includes no screen reader tests, so check with the screen reader your audience uses.
  • Rendering: Rarer code points depend on font coverage. Text that displays correctly on one device can show empty boxes on another, so a single successful rendering does not prove compatibility.
  • Editing: Combining marks, joiners and direction controls can make the cursor move unpredictably and make deleting or selecting text confusing.
  • Reading order: Direction overrides can make the displayed order differ from the stored order. This is why they are flagged in source code review and filenames.

If the text carries information that people need to find, read aloud or edit, publish a plain-text version as well, or use only the plain version. Keep styled or transformed text for decoration where losing it costs nothing.

How to find Unicode characters yourself

Search terms that lead to suitable tools and features include "Unicode inspector", "code point viewer", "Unicode character identifier", "show invisible characters", "zero-width character detector" and "homoglyph" or "confusables checker". The Unicode Consortium publishes confusable-character data as part of its security mechanisms standard (UTS #39), and many look-alike checkers build on it. Many code editors have settings to highlight invisible or ambiguous characters or to show whitespace and control characters. Look in your editor's settings for those terms, since menu locations vary and none were verified for this article.

Running a short script on your own machine avoids pasting text into a website, which matters if the text is private. A tool's appearance or marketing language does not tell you whether it stores or sends what you paste, and no tool's data practices were checked for this article. This Python example prints each code point with its name:

import unicodedata

text = "cafe\u0301\u200b test"
for ch in text:
    print(f"U+{ord(ch):04X}", unicodedata.name(ch, "<no name>"), repr(ch))

In JavaScript, iterating a string with for...of steps through code points rather than UTF-16 units, so emoji and other characters outside the Basic Multilingual Plane come out whole:

const text = "cafe\u0301\u200b test";
for (const ch of text) {
  console.log("U+" + ch.codePointAt(0).toString(16).toUpperCase().padStart(4, "0"), JSON.stringify(ch));
}

To find lines in a file that contain any non-ASCII character, GNU grep's Perl-compatible mode is commonly used as shown below. Behavior depends on your locale and on how grep was built, so check the output on your own system before relying on it.

grep -nP '[^\x00-\x7F]' file.txt

Limits of this review

This article covers general Unicode behavior. It does not include tests of specific apps, platforms, fonts or screen readers, and it does not evaluate any particular online tool. To decide whether a transformed string will work in a specific place, inspect its code points with one of the methods above, then paste it into the actual destination and check its display, search and screen reader output there.