Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brackets displays wrongly for right to left display style

The html code

<html dir="rtl">
<p>hello (world)</p>
</html>

you will see a page like this:

(hello (world

However,if I change the html code into

<html dir="rtl">
<p>hello (world) again</p>
</html>

Then the text displays normally:

 hello (world) again

Anyone can explain why this happens? How to fix the first example?

My browser is chrome

like image 955
user607722 Avatar asked Apr 21 '11 08:04

user607722


4 Answers

Or better you can try in CSS

*:after {
    content: "\200E‎";
}
like image 21
Adrian Ber Avatar answered Nov 18 '22 02:11

Adrian Ber


You just need to add the LRM character after the last bracket. HTML entity: &#x200E;

<html dir="rtl">
<body>
<p>hello (world)&#x200E;</p>
</body></html>

This tells the browser to interpret the brackets as left-to-right reading.

like image 159
Colin R. Turner Avatar answered Nov 18 '22 04:11

Colin R. Turner


Adding the special rlm character in css before and after your element solved all cases I've come across in Firefox and Chrome:

*:after {
    content: "\200E‎";
}
*:before {
    content: "\200E‎";
}
like image 6
DoPPeS Avatar answered Nov 18 '22 02:11

DoPPeS


Use &rlm; before (. Ex:

<html dir="rtl">
<body>
<p>hello &rlm;(world)</p>
</body></html>

if you are using javascript/svg Dom then

 aText = $('<span>').html(aText.replace("(","&rlm;(")).text();
 $("<p>").html(aText);

for other special Charactors

function getRTLText(aText,aChar) {
        if ( aText != undefined && aText.replace){
            aChar = (aChar === undefined )?"(":aChar;
            aText = $('<span>').html(aText.replace(aChar,"&rlm;"+aChar)).text();
        }
        return aText;
}

and call function

getRTLText("March / 2018","/");

like image 3
Veer Avatar answered Nov 18 '22 03:11

Veer