2

I'm using vscode and when I try to print this

print('شیرینی پزی')

the output of terminal is

ی‌ز‌پ ی‌ن‌ی‌ر‌ی‌ش

what should I do

  • Does this answer your question? [How to get RTL (right-to-left) text working in VS Code integrated terminal?](https://stackoverflow.com/questions/75985838/how-to-get-rtl-right-to-left-text-working-in-vs-code-integrated-terminal) – starball Aug 31 '23 at 05:23

1 Answers1

2

Note: The following solution is for displaying the RTL texts. Don't use the output in your code. It's just for printing in wherever RTL texts are messed up.

First install arabic_reshaper and bidi

pip install arabic-reshaper
pip install python-bidi

Then, use the following function:

import arabic_reshaper
from bidi.algorithm import get_display

def convert(text):
    reshaped_text = arabic_reshaper.reshape(text)
    converted = get_display(reshaped_text)
    return converted
print(convert('شیرینی پزی'))

The output:

>>> شیرینی پزی
Asdoost
  • 316
  • 1
  • 2
  • 15