Print Arabic or any string from right to left for a string in Linux using Python

The simplest example:

city = "‏المكلا‎"
print(city)

I expect the output to be:

‏المكلا‎

But in fact, the conclusion is the return line (the letters look a little different, because they have initial, middle and final forms). I cannot paste it here because copying inserts the row order again.

How to print Arabic in Linux terminal? The surrounding text is from left to right (LTR), and only this line should be from right to left (RTL). Is there a UFT-8 character that can tell the terminal that?

+4
source share
1 answer

To create a string with the RTL character:

rtl = u'\u200f'

Python 3 UTF, "u" .

, , .

test = 'Hello world'
test = test[::-1]
# test == 'dlroW olleH'

python-bidi, . ()

0

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


All Articles