Mixed Direction Text Fixer

Fix Arabic lines that jumble English names, numbers and URLs by wrapping each left-to-right run properly.

How to use

What it checks and how it works

When Arabic text contains Latin words, numbers or punctuation, the Unicode Bidirectional Algorithm (UAX #9) decides the display order, and the result can look scrambled at the edges of a run, for example a full stop that lands on the wrong side of an English name. The tool finds each left-to-right run in lines that mix both and wraps it in a left-to-right isolate (LRI and PDI), the method UAX #9 introduced for this, or follows it with a right-to-left mark (RLM) for older software. The direction levels reported come from the bidi-js implementation of UAX #9. The added characters are invisible, so do not use the result for URLs, file names or code that a program reads. In web pages, prefer the dir attribute or the bdi element where you control the markup.

Why does my full stop jump to the wrong side of an English name?

Punctuation next to a left-to-right run takes the direction of its neighbours under the bidi rules. Wrapping the run in an isolate stops it from reaching the punctuation.

Isolates or marks?

Isolates are the method the Unicode standard recommends for new text. Marks work in older software that does not read isolates.

Should I use this on website text?

On a page you control, mark up the foreign run with dir or the bdi element instead. Use this tool for plain text, such as messages, spreadsheets and captions.

Sources

Related tools

Privacy

Runs in your browser; nothing is uploaded. The interactive tool needs JavaScript.