DublioStart dubbing

Guide

Right-to-left subtitles: why the full stop lands on the wrong side, and how to fix it

You open a Persian subtitle file and the full stop sits at the start of the line. It looks like a bug in the file. It is not. It is how text of two directions is laid out, and it has a two-character fix.

The symptom

Here is the same Persian sentence twice, in a box that starts from left to right, which is how many subtitle renderers begin. Your browser is drawing both.

این یک آزمایش است.

Without marks: the full stop jumps to the start of the sentence, on the right.

‫این یک آزمایش است.‬

With a right-to-left embedding around the line: the full stop is at the end, on the left, where it belongs.

Quotation marks, brackets and ellipses do the same. They jump to the wrong end, and parentheses can end up looking mirrored.

«سلام!» گفت (خوب)...

Without marks.

‫«سلام!» گفت (خوب)...‬

With marks.

Why it happens

Unicode decides the visual order of mixed-direction text with a set of rules called the bidirectional algorithm. Letters have a direction: Persian and Arabic letters are right to left, Latin letters left to right. Some characters have none. A full stop, an exclamation mark, a colon, quotation marks, brackets and an ellipsis are neutral. A neutral character takes the direction of the text around it. At the very end of a line there is nothing after it, so it takes the direction of the paragraph itself.

If the renderer starts the line as left to right, a full stop at the end of a Persian sentence becomes left to right, and the rules put it on the right of the sentence, which is where a Persian reader starts reading. That is why the dot seems to be at the beginning.

This also explains why some lines are fine. The Arabic question mark (؟) and the Arabic comma (،) are Arabic-script characters with their own direction, so they stay in place. Only the neutral marks misbehave. A file that mostly uses those two looks right until a line ends with a full stop.

The fix

Tell the renderer the direction of each line. Two invisible characters do it:

The line is then laid out as a right-to-left line, and the neutral marks at its ends take the right-to-left direction. Wrap each line of the subtitle on its own. A two-line subtitle has two wrapped lines. If the line has HTML tags such as <i>, put the marks outside them, so the line starts with the first mark and ends with the last.

<U+202B>این یک آزمایش است.<U+202C>

A lighter alternative is a single U+200F RIGHT-TO-LEFT MARK at the end of each line. It tells the renderer that what comes after the full stop is right to left, so the dot is placed between two right-to-left things and stays in the right place. If a player draws the embedding marks as visible symbols, try this one.

You do not have to type the characters by hand. Most text editors with Unicode support can insert them from a character code, and a script or a tool can add them to a whole file at once. Our free SRT fixer does exactly this in your browser.

Other things that look like the same bug

Or let Dublio do it

Dublio wraps every line of every right-to-left subtitle, in the SRT file and in the burned-in subtitles, for Persian, Arabic, Urdu and Hebrew. You do not need to know any of this to get subtitles with the punctuation on the correct side.

Dub or subtitle your next video

Dublio translates your video, lets you edit the script line by line, and gives you the dubbed video, SRT subtitles and audio files. 10 free minutes every month, no card.