Robert Sheldon
Robert Sheldon

Reputation: 90

print unicode characters in terminal with python 3

I'm currently writing a 2-player chess game for the terminal and I'd like to be able to print the actual unicode characters for the pieces (for instance, http://en.wikipedia.org/wiki/Rook_(chess)#Unicode). How would one go about printing actual unicode representations in python 3 instead of escape characters? does the charset of the terminal need to be changed (I primarily use windows and linux), and can that be done by a system call in the program itself?

Upvotes: 4

Views: 2763

Answers (2)

Ashwini Chaudhary
Ashwini Chaudhary

Reputation: 251136

Python 3 doesn't need anything extra for that, just use print().

>>> print('القاموس العربي')
القاموس العربي

Upvotes: 3

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799310

Err... print them...

3>> print('♔♕♖')
♔♕♖

Windows will probably need chcp 65001 before running the script.

Upvotes: 4

Related Questions