0

How to print chess symbol in windows cmd?

print '♛'

I got 'тЩЫ'.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
dett
  • 83
  • 6

2 Answers2

3

The Windows Cmd window uses Code Page 437 which doesn't contain any chess characters.

>>> print ''.join([chr(x) for x in range(256)])
 ☺☻♥♦
♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]
^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡
«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²
■

Python 3.3 just added the ability to use code page 65001 which is UTF-8. Use the command chcp 65001 before running Python.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
  • @MarkTolonen, very good point. Doesn't change anything though, as I doubt any other code pages used by cmd include chess symbols. – Mark Ransom Mar 08 '12 at 13:56
2

You have a couple of options that I can see, an easy one and a hard one...

  1. Use an alternative terminal than windows cmd. I like console.

  2. Launch the console using a Shell Link (.LNK) file, which allows you to specify a font. You might not get all of unicode, but other fonts definitely have better support for funny characters than the default. (Stolen from this answer).

Community
  • 1
  • 1
wim
  • 338,267
  • 99
  • 616
  • 750