Identify Right-to-Left Unicode Controls

How to spot right-to-left override (U+202E) and other bidirectional Unicode controls, what they change, and when plain text is the safer choice.

Right-to-left Unicode controls are invisible characters that tell a renderer how to order text on screen. The best known is the right-to-left override, U+202E, which can make ordinary Latin text appear backwards without changing a single stored letter. This guide explains how to identify these controls, what they actually do, and when you should use them, replace them, or strip them out.

Short answer: is a right-to-left override suitable for your use?

For displaying genuine mixed-direction text, such as an English product name inside an Arabic or Hebrew sentence, bidirectional controls are a legitimate tool. Even there, the Unicode Bidirectional Algorithm (UAX #9) and W3C internationalization guidance favor the newer isolate controls, or markup such as the HTML dir attribute and the bdi element, over the older override and embedding controls.

For making text look reversed as a style effect, the override is a poor choice. Its only benefit is that the stored text stays in normal order. The decisive tradeoff is that display depends entirely on each destination's bidirectional support, and the same character is a known way to disguise file names and source code, so some platforms flag or remove it.

Plain text without controls is preferable for anything that will be searched, edited, read by assistive technology, used as a file name, username or URL, or pasted into source code.

What a right-to-left control actually changes

The word "reverse" covers several different techniques, and they behave very differently once text is copied:

  • Bidirectional controls (such as U+202E): the stored characters keep their original order. An invisible control is added, and a renderer that follows the Unicode Bidirectional Algorithm displays the following characters right to left.
  • Character reversal tools: the stored characters themselves are rearranged into reverse order. What you copy is the reversed string.
  • Mirrored or upside-down text: letters are replaced with different Unicode characters that resemble flipped glyphs. The stored text is a new set of characters.
  • CSS presentation: styles such as direction: rtl combined with unicode-bidi: bidi-override reorder display in a web page only. The underlying text is unchanged and no control character is stored.

Only the first and last of these are purely visual. With a bidirectional control, the visual result travels with the text only if the control character is copied along and the destination honors it.

An illustrative example

The stored string below uses escape notation so the control is visible. In a renderer that applies the bidirectional algorithm, the characters after U+202E are displayed in reverse order until the end of the paragraph or a closing U+202C.

Stored:     report\u202Etxt.exe
Displayed:  reportexe.txt
Actual file extension: .exe

This is why the override is associated with file-name spoofing: the visible name suggests a text file while the real extension is an executable. The same idea, applied to source code so that the code a reviewer sees differs from the code a compiler reads, was publicized as the "Trojan Source" technique.

Two cautions apply to reversal under an override. Combining marks, such as accents stored as separate code points, may not stay attached to the right base letter, because the algorithm treats reordering of combining marks as an optional step that renderers handle differently. Emoji built from several code points, such as flags or joined family sequences, may also break apart or display unpredictably. Results vary by renderer, and no tested outcome is supplied here for any specific application.

Under right-to-left display, characters with mirrored forms, such as parentheses and square brackets, may also be drawn flipped. This is defined behavior, not an error, but it can make reversed-looking text even harder to read.

The right-to-left and related controls to look for

These are the Unicode characters that affect bidirectional ordering. All are invisible in normal display. UTF-8 byte sequences are included because they are what you will see in a hex dump.

Code point | Abbreviation | Name | Effect | UTF-8 bytes
U+200E | LRM | Left-to-right mark | Invisible strong left-to-right character | E2 80 8E
U+200F | RLM | Right-to-left mark | Invisible strong right-to-left character | E2 80 8F
U+061C | ALM | Arabic letter mark | Invisible Arabic-type character | D8 9C
U+202A | LRE | Left-to-right embedding | Starts a left-to-right embedding, ended by PDF | E2 80 AA
U+202B | RLE | Right-to-left embedding | Starts a right-to-left embedding, ended by PDF | E2 80 AB
U+202C | PDF | Pop directional formatting | Ends the most recent embedding or override | E2 80 AC
U+202D | LRO | Left-to-right override | Forces following text to display left to right | E2 80 AD
U+202E | RLO | Right-to-left override | Forces following text to display right to left | E2 80 AE
U+2066 | LRI | Left-to-right isolate | Isolates following text as left to right, ended by PDI | E2 81 A6
U+2067 | RLI | Right-to-left isolate | Isolates following text as right to left, ended by PDI | E2 81 A7
U+2068 | FSI | First strong isolate | Isolates text, direction taken from its first strong character | E2 81 A8
U+2069 | PDI | Pop directional isolate | Ends the most recent isolate | E2 81 A9

The overrides (LRO and RLO) are the ones that reverse the apparent order of Latin letters. Embeddings and isolates change how neutral characters and runs are grouped, and the marks nudge the direction of nearby punctuation and numbers. An unterminated override or embedding continues to the end of the paragraph, which is how a single stray control can affect text well beyond the spot where it was inserted.

How to identify these controls

Because the characters are invisible, you need to inspect code points rather than rendered text. Useful clues that a bidirectional control is present include text that reads backwards while copy-and-paste produces normal order, a cursor that jumps in an unexpected direction when you use the arrow keys, a string whose length is longer than the visible characters suggest, and file names whose apparent extension does not match how the system treats the file.

In a terminal with a UTF-8 locale, GNU grep with Perl-compatible patterns can list lines containing any of the controls above:

grep -nP '[\x{200E}\x{200F}\x{061C}\x{202A}-\x{202E}\x{2066}-\x{2069}]' file.txt

A hex dump shows the raw bytes, so you can match them against the UTF-8 column in the table. For example, the right-to-left override appears as e2 80 ae:

printf 'report\xe2\x80\xaetxt.exe' | xxd

In Python, the standard unicodedata module reports each character's name and bidirectional class, which lets you label every control by its position:

import unicodedata

BIDI_CONTROLS = {"LRE", "RLE", "PDF", "LRO", "RLO", "LRI", "RLI", "FSI", "PDI"}
MARKS = {"\u200e", "\u200f", "\u061c"}

def find_bidi_controls(text):
    for i, ch in enumerate(text):
        if unicodedata.bidirectional(ch) in BIDI_CONTROLS or ch in MARKS:
            yield i, f"U+{ord(ch):04X}", unicodedata.name(ch)

for hit in find_bidi_controls("report\u202etxt.exe"):
    print(hit)

Many code editors and code-review tools can highlight invisible or bidirectional characters, but settings names and menu locations differ between products and versions. No specific tool, setting or navigation path has been verified for this article, so check your editor's documentation for options related to "bidirectional", "invisible" or "control" characters. Treat any online inspector that asks you to paste text with the same care you would give any service that receives your data; its privacy practices cannot be judged from its appearance.

Useful search terms include "bidirectional control characters", "bidi controls", "Unicode Bidirectional Algorithm", "UAX #9", "right-to-left override U+202E" and "Trojan Source".

Copying, sharing, accessibility and search

When you copy text that contains a right-to-left control, the control is normally part of the selection, so the destination receives the original letter order plus the invisible character. Whether it then looks reversed depends on the destination. Some applications apply the bidirectional algorithm, some sanitize or strip format characters, and some show a placeholder or warning. A result that looks right in one app should not be assumed to look the same anywhere else; no destination-specific tests are available here.

Search and matching work on stored characters. Text that displays as a reversed word is still stored in forward order, so searching for the reversed spelling will not find it, while searching for the normal spelling may or may not match depending on whether the search tool ignores format characters. The invisible control can also make two strings that look identical compare as different, which matters for usernames, file names and identifiers.

For assistive technology, there is no supplied documentation or test showing how particular screen readers handle overrides. Because screen readers generally work from the underlying text, the spoken order may not match what sighted readers see, which can be confusing either way. If the reversed look carries meaning, provide a plain-text equivalent nearby.

Editing text with overrides is error-prone: cursor movement, selection and deletion follow logical order while the screen shows visual order. When you need stable, editable text, remove the controls, or for genuine mixed-direction content, replace overrides and embeddings with isolates or with markup that sets direction explicitly.

When to keep, replace or remove the controls

  • Keep marks or isolates when they correctly order punctuation, numbers or embedded names in real right-to-left language text.
  • Replace overrides and embeddings with isolates or HTML direction markup when you control the content and need mixed-direction display.
  • Remove controls from file names, usernames, identifiers, URLs and source code unless there is a documented reason for them.
  • Avoid using the right-to-left override as a decorative reversed-text effect; if a reversed look is essential, store the reversed characters directly and keep a plain-text version for search and accessibility.