HTML with Hebrew characters displaying strange

I have a chat that displays chats like this

Username: my chat message

Username2: chat message

But then someone registered using Hebrew characters in their username, when he publishes our chat, it is not displayed correctly. It will be displayed as follows

תירבע: 12345

Username: my chat message

Username2: chat message

This only happens if it sends numbers. HTML example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Chatbox</title></head> <body> <div><span><a target="_BLANK" style="" href="#">&#1514;&#1497;&#1512;&#1489;&#1506;</a>:</span><span>12345</span></div> <div><span><a target="_BLANK" style="" href="#">&#1514;&#1497;&#1512;&#1489;&#1506;</a>:</span><span>this is not numbers so it is displayed correctly</span></div> <div><span><a target="_BLANK" style="" href="#">Username1</a>:</span><span>message1</span></div> <div><span><a target="_BLANK" style="" href="#">Useraname2</a>:</span><span>message2</span></div> </body> </html> 

And the result of this is

 תירבע:12345 תירבע:this is not numbers so it is displayed correctly Username1:message1 Useraname2:message2 

How can I display it correctly so that the username is first?

+6
source share
3 answers

Add this CSS rule:

 span a { unicode-bidi: embed; } 
+4
source

Use in this case

 a { unicode-bidi: embed; } 

In general, set unicode-bidi: embed to any element that may contain text with a directivity opposite to that of the surrounding text. Although, for example, simply embedding Arabic words in English text (or vice versa) usually does not require this (since the situation is handled by the inherent directivity of the letters), this is a useful precaution when numbers, punctuation or other directional neutral characters may be involved.

Sample HTML <bdo> , for example. <bdo><a ...>...</a></bdo> , but it is not implemented as such, so you will need to create a backup using a { unicode-bidi: embed; } a { unicode-bidi: embed; } in CSS and, to cover older versions of IE, document.createElement('bdo') in the JavaScript code.

The dir=ltr attribute in a may have the same effect, but this is a bug in browsers. According to the HTML 4.01 specification, this should only affect the direction of the neutral text (Hebrew text is not necessarily), and dir=ltr is the initial value.

+4
source

You should look for the language code you want to use.

This url can help you. http://www.w3schools.com/tags/ref_language_codes.asp

-1
source

Source: https://habr.com/ru/post/906365/


All Articles