[Tutor] Re: printing special characters
dman
dsh8290@rit.edu
Tue, 25 Sep 2001 12:31:18 -0400
[...]
| Is there a cross-platform way to print special characters such as
| the degree symbol in a Python program?
If you can use Unicode, the degree symbol is character is 00B0. I
used that recently in a small java/swing program I had to write. It
does, of course, depend on the environment the user has. If the
environment is "archaic"[1] then you probably can't print any special
symbols like that.
With python 1.5.2 on a Debian Woody system running in gnome-terminal
version 1.4.0 and the fonts I have installed,
print chr( 0xB0 )
works just fine. (hmm, 1.5.2 doesn't even have unicode. Maybe that
character is in iso8859 too?)
-D
[1] By "archaic" I mean a system that can only handle pure-ASCII
(7 bits). I think these systems are all too common these days.
The conversion to unicode is quite slow.