Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: block character will not print

In IDLE, print(chr(219)) (219's the block character) outputs "Û".

Is there any way to get it to output the block character instead?

This might actually be some sort of computer-wide problem, as I cannot seem to get the block character to print from anywhere, copying it out of charmap and into any textbox just results in the Û.

like image 387
Name McChange Avatar asked Oct 02 '12 23:10

Name McChange


1 Answers

Use the correct character set.

3>> print(bytes((219,)).decode('cp437'))
█
3>> ord(bytes((219,)).decode('cp437'))
9608
3>> hex(9608)
'0x2588'
3>> print('\u2588')
█

Unicode Character 'FULL BLOCK' (U+2588)

like image 75
Ignacio Vazquez-Abrams Avatar answered Sep 22 '22 01:09

Ignacio Vazquez-Abrams