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?
-
this might help stackoverflow.com/questions/507123/…Ashwini Chaudhary– Ashwini Chaudhary2012-06-25 22:25:29 +00:00Commented Jun 25, 2012 at 22:25
-
Having anything else than line printing of ascii and making it work in both Windows terminal and Linux terminals needs a library. UniCurses is a Python library that wraps curses/PDCurses. I haven't used it, but it might be worth a try.Lennart Regebro– Lennart Regebro2012-06-26 11:54:07 +00:00Commented Jun 26, 2012 at 11:54
-
See also: stackoverflow.com/a/30505612/788700Adobe– Adobe2015-05-28 11:43:44 +00:00Commented May 28, 2015 at 11:43
Add a comment
|
2 Answers
Err... print them...
3>> print('♔♕♖')
♔♕♖
Windows will probably need chcp 65001 before running the script.
6 Comments
Robert Sheldon
After executing
chcp 65001 I get this error when trying to run Python: "Fatal Python error: Py_Initialize: can't initialize sys standard streams LookupError: unknown encoding: cp65001"Ignacio Vazquez-Abrams
That would be a problem with that particular Python installation then.
Robert Sheldon
it looks like this is going to be a linux-only program. Windows terminal seems to be very tetchy with nonasci, I can't even echo those characters in the terminal after I change to 65001, it just exits. Thanks for your input
Mark Tolonen
Support for cp65001 was added in Python3.3, but it still doesn't work right.
|