I want to print a Persian phrase (right-to-left) in a Python console application.
It's okay if all characters are in Persian. However, if it's mixed with English (including the ending dot (.
), it shows the text in the wrong order.
Examples:
این خوب است # this is okay
این خوب است.
# the dot must be on the left-most side, not the right-most side.
# the problem exists even in this editor.
این متن شامل English است.
The last one must be printed as:
.است English این متن شامل
To type the above, I typed it in the wrong order to show the right display order from right to left!
Python test with the same results:
>>> print("این خوب است")
این خوب است
>>> print("این خوب است.")
این خوب است.
>>> print("این متن شامل English است.")
این متن شامل English است.
Anyways, this answer seems like a solution, but it's in Java and I couldn't test it in Python. I tested it but it just prints some numbers inside the string.
Also to get the actual vs. display order (the must display order) check this website and copy and paste the third example in it, it gives the correct order, I just don't know how to use it in Python.