Arabic or Hebrew Text Flips When Pasted? Fix It on Windows
By Khushi Yadav
When Arabic, Hebrew or Persian text looks right in one app and comes out reordered in another, the clipboard usually isn't changing the characters. The text is stored in logical order (the order it was typed), and each app decides how to display it. The destination's paragraph direction, plus any invisible direction marks or HTML dir attributes that came along with the copy, decides whether numbers, punctuation and English words land where you expect. Fix the destination's direction for documents, and strip the invisible marks for data fields such as paths, URLs and IDs.
Why mixed right-to-left text reorders after a paste
Unicode stores bidirectional ("bidi") text in logical order. Display order is worked out later by the Unicode Bidirectional Algorithm, which looks at each character's direction type:
- Strong characters have a fixed direction: Latin letters are left-to-right, Hebrew and Arabic letters are right-to-left.
- Weak characters, such as digits, take their direction from what comes before them.
- Neutral characters, such as spaces and most punctuation, follow their neighbours or, between opposite directions, the paragraph's overall direction.
Microsoft's globalization docs give a clear example. In a left-to-right line containing an Arabic word, the number 4 and another Arabic word, the 4 joins the right-to-left run and appears after the first Arabic word rather than where an English reader expects it. Paste the same characters into a field with a different base direction and the visual result changes, even though not one character changed.
Copies from browsers and Office usually put two versions on the clipboard: plain text and HTML. The HTML version can carry dir="rtl" on paragraphs and elements. The plain-text version can only carry invisible control characters. How Windows treats rich text versus plain text explains how the destination picks one.
| Destination takes | What sets direction | Typical result |
|---|---|---|
| HTML (Word, Outlook, many rich editors) | dir attributes plus any marks in the text | Usually keeps the source layout |
| Plain text (Notepad, terminals, many web forms) | Only the destination's own direction plus invisible marks | Mixed lines can reorder |
| Paste as plain text in a rich editor | Destination paragraph direction | Direction from the source is lost |
The invisible characters that travel with RTL text
These are the Unicode directional formatting characters Microsoft documents. None of them takes up visible space.
| Character | Code point | What it does |
|---|---|---|
| LEFT-TO-RIGHT MARK (LRM) | U+200E | Acts like an invisible left-to-right letter |
| RIGHT-TO-LEFT MARK (RLM) | U+200F | Acts like an invisible right-to-left letter |
| ARABIC LETTER MARK (ALM) | U+061C | Acts like an invisible Arabic letter |
| LRE, RLE, PDF | U+202A, U+202B, U+202C | Older embedding controls (start LTR, start RTL, end) |
| LRO, RLO | U+202D, U+202E | Override the direction of the enclosed text |
| LRI, RLI, FSI, PDI | U+2066 to U+2069 | Isolates, which keep a run from affecting its neighbours |
Microsoft's example shows the marks doing their job: put an LRM before the 4 and an RLM after it, and the number is treated as its own left-to-right run between right-to-left words. That is useful in a document. In a file path, a URL, a username or an ID field, the same marks are invisible junk that can break a match or a lookup.
Windows clipboard history stores text and HTML items, so the marks are kept in history too. Two history items that differ only by an RLM look identical in the Win+V panel, so the panel can't tell you which one is clean.
How to see what is actually on the clipboard
With PowerShell
Copy the text, then run this in PowerShell. It lists only the direction marks (plus the no-break space U+00A0, which often rides along from web pages):
(Get-Clipboard -Raw).ToCharArray() |
Where-Object { "$_" -match '[\u00A0\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]' } |
ForEach-Object { 'U+{0:X4}' -f [int]$_ }
No output means none of those characters is present. To see every character's code point instead:
[int[]][char[]](Get-Clipboard -Raw) | ForEach-Object { '{0:X4}' -f $_ }
Both commands only read the clipboard. They work in Windows PowerShell 5.1 and PowerShell 7. The PowerShell clipboard cheat sheet has more read-only commands.
In VS Code
Paste into a new file. Since version 1.63, VS Code highlights uncommon invisible characters in source files by default, so stray marks show up as boxes. Markdown files aren't highlighted by default. To find every mark, open Find (Ctrl+F), turn on regular expressions (Alt+R) and search for:
[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]
Strip the marks when the destination is a data field
When the destination should be plain left-to-right data (a path, URL, email address, command, CSV column or form ID), remove the marks before pasting. This PowerShell line reads the clipboard, removes the controls and puts the cleaned text back:
Set-Clipboard -Value ((Get-Clipboard -Raw) -replace '[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]', '')
In VS Code, run the same regex search above and replace with nothing. Regex vs clipboard tools for cleaning pasted text covers bulk find-and-replace, and how to remove hidden characters from copied text covers other invisible characters such as soft hyphens.
Don't strip marks from Arabic or Hebrew prose that will be published as prose. There, the marks are often what keeps numbers and punctuation in the right place. Fix the paragraph direction instead.
Fix the destination when it is a document
Word and Outlook
Pasting with source formatting usually keeps the direction from an HTML copy. If a paragraph comes out with the wrong direction, select it and choose the Right-to-left paragraph button in the Paragraph group on the Home tab. That button appears only after a right-to-left language is added under File > Options > Language.
Keep Text Only drops HTML formatting, including dir, but keeps any marks inside the text, so a line can change order after a plain paste. How to paste without formatting on Windows covers the paste options.
Web forms, chat apps and editors in the browser
Many web editors take only plain text or clean up pasted HTML, so the page's own direction (often left-to-right) wins. If the app has a text-direction control, use it. If not, paste the right-to-left phrase and the English or numeric part separately so each lands in its own run.
Terminals and code
Paths, URLs, JSON and commands should be pure left-to-right data, so strip the marks before pasting. Terminals take plain text only; why pasting into terminals strips formatting explains the rest.
Excel
For identifiers such as account numbers or national IDs, keep the digits in a cell of their own with no label mixed in, and strip marks if the value came from a web page. A cell that holds invisible marks may not match a lookup or a filter even though it looks identical.
A quick decision checklist
- Decide whether the destination is a document (keep direction information) or a data field (strip it).
- For a document, paste with formatting and fix paragraph direction in the destination if needed.
- For a data field, inspect the clipboard, strip the marks, then paste.
- Check digits and punctuation in the result, not in the clipboard history preview.
- Don't add LRM or RLM characters by trial and error until one app looks right. The next app will interpret them its own way.
Edge Drop and right-to-left text
Clipboard managers store the characters they are given, marks included. Edge Drop keeps a copied text item's HTML (up to 32,768 characters) alongside the text and writes both back when you click the card to paste, so dir attributes in that HTML survive the round trip. To paste a text card's content without its HTML, right-click the card and choose Paste as plain text (the menu shows that item only on text cards that have formatting or tabs), or hold Shift while you click it. Its own interface is available in Arabic, Persian and Hebrew with a right-to-left layout; how to change language and RTL layout shows the setting, and RTL clipboard shelves on Windows covers layout issues in shelf-style tools.
FAQ
Why does Hebrew text come out backwards in some apps?
Usually the app is displaying it in a left-to-right paragraph, or it doesn't apply the bidirectional algorithm. The stored characters are in the correct logical order; set the paragraph or field direction to right-to-left, or use an app with proper bidi support.
Does Windows clipboard history change RTL text?
No. History stores the text and HTML it is given, invisible marks included. Its preview won't show the marks, so inspect the text before an important paste.
Is it safe to delete every LRM and RLM character?
In data such as paths, IDs, URLs and code, yes. In right-to-left prose, removing them can move numbers and punctuation, so fix the paragraph direction instead.
Related reading
- Clipboard Managers for Arabic, Hebrew and Persian on Windows
- Rich Text vs Plain Text on the Windows Clipboard
- How to Remove Hidden Characters From Copied Text
- PowerShell Clipboard Cheat Sheet: Get-Clipboard and Set-Clipboard
Sources
- Text directionality (Microsoft Learn) — logical vs visual order, strong/weak/neutral characters, the directional control characters and the LRM/RLM example.
- Unicode Bidirectional Algorithm, UAX #9 (Unicode) — how display order is calculated.
- Structural markup and right-to-left text in HTML (W3C) — the
dirattribute that HTML copies can carry. - Using right-to-left languages in Office (Microsoft Support) — the Right-to-left paragraph button and enabling an RTL editing language.
- Get-Clipboard (Microsoft Learn) — the
-Rawparameter. - Set-Clipboard (Microsoft Learn) — writing cleaned text back.
- Visual Studio Code 1.63 release notes — invisible-character highlighting.
- Using the clipboard (Microsoft Support) — clipboard history stores text, HTML and bitmap items.
Khushi Yadav writes Edge Drop's workflow and design guides and is a B.Tech Computer Science Engineering student. Khushi's posts are checked against Microsoft's documentation and the Edge Drop fact sheet.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge Drop vs Win+V · Support
Free · Lightweight · Privacy First