Search code examples
htmlinternet-explorerarabicright-to-left

IE reversing Arabic charterers automatically


I am currently using Arabic language to display message on Internet Explorer. Web browser is reversing Arabic character automatically I believe which is correct behavior but I don’t want browser should automatically reverse my Arabic characters. Do you have any idea which setting will help me to disable automatic reversing by browser?

For example:

HTML page source code:

<html lang="ar" dir="ltr">
    <body>
        <p>
            &#1570;
        </p>
        <p>
            &#1581;
        </p>
        <div>
            &#1570;&#1581;
        </div>
    </body>
    </html>

Actual output:

آ

ح

آح

Expected output:

آ

ح

ح آ


Solution

  • This is indeed the correct behaviour - in a predominantly left-to-right context runs of Arabic characters should be rendered right-to-left, with the whole run then placed at the appropriate point in the main left-to-right flow. But there are additional non-printing control characters you can insert into the text to override the default bidirectional rendering behaviour.

    Placing the "left to right override" character (&#x202d;) before the Arabic text will force the renderer to display the characters from left to right instead of right to left. You should also add a &#x202c; ("pop directional formatting") after the run to restore the normal rendering behaviour for following text.

    &#x202d;&#1570;&#1581;&#x202c;
    

    renders as

    ‭آح‬

    You get the same result by inserting the Arabic characters in reverse order:

    &#1581;&#1570;
    

    renders as

    حآ

    (I don't speak Arabic so I don't know which of these two orderings is the correct logical order - the way the Unicode rendering algorithms work you're supposed to provide characters in the stream in their logical order regardless of the reading direction of a particular language)