5

I am running windows 7 and using a python script that outputs some strings in arabic to windows cmd. This is what I get:

enter image description here

How do I configure cmd show arabic strings correctly?

Paulo Bu
  • 29,294
  • 6
  • 74
  • 73
minerals
  • 6,090
  • 17
  • 62
  • 107
  • you must select an encoding and font for your console that supports the character set you want ... (maybe just the font is sufficient) – Joran Beasley Sep 12 '13 at 17:08

1 Answers1

13

Change your cmd's code page to the encoding you're outputting:

chcp 1256

That 1256 is an Arabic code page for Windows If you're outputting in another encoding, just find them in the whole list of code pages and change 1256 to the identifier you want in the command.

Hint: UTF-8 is 65001

Note: To show other characters than ascii, Window's cmd's current font must be changed to Lucida Console in properties. It's weird I know... Windows :)

Hope this helps!

Paulo Bu
  • 29,294
  • 6
  • 74
  • 73
  • hmm, but how do I actually change it from within the script? Cause I double click script.py and new cmd instance is created without chcp 1256, call('chcp 1256') does not work :( – minerals Sep 12 '13 at 17:19
  • I see, don't double click it. Go to Run > cmd and open a console. Then issue the `chcp` command. You can't change the console's output encoding from within the script. – Paulo Bu Sep 12 '13 at 17:22
  • @JoranBeasley of course. That's what I meant :) Thanks for the clarification! – Paulo Bu Sep 12 '13 at 17:25
  • Well, I figured out that I can actually use cygwin. Running the script from cygwin with "Courier New" font does the job. – minerals Sep 12 '13 at 17:30
  • @tasty: That's great! I'm glad you made it. – Paulo Bu Sep 12 '13 at 17:31
  • But **Lucida Console** font doesn't support Arabic characters as listed in [Microsoft Lucida Console font](https://learn.microsoft.com/en-us/typography/font-list/lucida-console). You should use **DejaVu Sans Mono** or **Segoe UI** font instead. – iTzVoko Jun 09 '23 at 14:41