how do I display the degree symbol?

I’m totally perplexed here - what is the appropriate character number for the degree symbol? After 30 minutes of fruitless hacking and Googling, I realized I could just print out the entire character set in a test panel, which revealed that character 161 works on my system. However, since every other reference I’ve seen lists the degree symbol as # 176, I’m not confident that this is going to work on other systems. I’m using ANSI builds (the rest of our code will break if we don’t), and I’m happy to force the locale and character encodings if that will help. (Mac OS 10.6.8, Python 2.7.2, wxPython 2.8.12.0 or 2.9.2)

thanks,

Nat

Hi Nat,

I'm totally perplexed here - what is the appropriate character number for
the degree symbol? After 30 minutes of fruitless hacking and Googling, I
realized I could just print out the entire character set in a test panel,
which revealed that character 161 works on my system. However, since every
other reference I've seen lists the degree symbol as # 176, I'm not
confident that this is going to work on other systems. I'm using ANSI
builds

I believe this is the main source of all your problems :smiley:

Looking for "degree symbol ansi" on Google spits out any kind of
numeric value depending on the locale and/or encodings. Sorry I can't
offer a better suggestion, you should wait for the encodings gurus for
a nice way to implement it. Or switch to an unicode build.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

import PyQt4.QtGui

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named pygtk

···

On 17 August 2011 00:37, Nat Echols <nathaniel.echols@gmail.com> wrote:

import wx

Yes, switching to the Unicode will be best. Unless pigs fly or something else just as startling happens then I don't expect that there are going to be any more ansi builds released.

···

On 8/16/11 2:51 PM, Andrea Gavana wrote:

Hi Nat,

On 17 August 2011 00:37, Nat Echols<nathaniel.echols@gmail.com> wrote:

I'm totally perplexed here - what is the appropriate character number for
the degree symbol? After 30 minutes of fruitless hacking and Googling, I
realized I could just print out the entire character set in a test panel,
which revealed that character 161 works on my system. However, since every
other reference I've seen lists the degree symbol as # 176, I'm not
confident that this is going to work on other systems. I'm using ANSI
builds

I believe this is the main source of all your problems :smiley:

Looking for "degree symbol ansi" on Google spits out any kind of
numeric value depending on the locale and/or encodings. Sorry I can't
offer a better suggestion, you should wait for the encodings gurus for
a nice way to implement it. Or switch to an unicode build.

--
Robin Dunn
Software Craftsman

I'm totally perplexed here - what is the appropriate character number for
the degree symbol? After 30 minutes of fruitless hacking and Googling, I
realized I could just print out the entire character set in a test panel,
which revealed that character 161 works on my system. However, since every
other reference I've seen lists the degree symbol as # 176, I'm not
confident that this is going to work on other systems. I'm using ANSI
builds (the rest of our code will break if we don't), and I'm happy to force
the locale and character encodings if that will help. (Mac OS 10.6.8,
Python 2.7.2, wxPython 2.8.12.0 or 2.9.2)

The unicode code point for the "degree" is 0x00b0.

unicodedata.name(u'\u00b0')

DEGREE SIGN

The code points for the following codings are:

codings = ['iso-8859-1', 'cp437', 'cp1252',\

... 'cp850', 'mac-roman']

for cod in codings:

... print '{:15} : {}'.format(cod, repr(u'\u00b0'.encode(cod)))
...
iso-8859-1 : '\xb0'
cp437 : '\xf8'
cp1252 : '\xb0'
cp850 : '\xf8'
mac-roman : '\xa1'

jmf

···

On 16 août, 23:37, Nat Echols <nathaniel.ech...@gmail.com> wrote:

Sorry, I forgot my comment.

The problem is not on the wx-builds side. The real problem
is most probably, you are not working in a unicode mode
on the Python level. The GUI only plays a secondary role.

The unicode code point for the "degree" is 0x00b0.

unicodedata.name(u'\u00b0')

DEGREE SIGN

The code points for the following codings are:

codings = ['iso-8859-1', 'cp437', 'cp1252',\

... 'cp850', 'mac-roman']

for cod in codings:

... print '{:15} : {}'.format(cod, repr(u'\u00b0'.encode(cod)))
...
iso-8859-1 : '\xb0'
cp437 : '\xf8'
cp1252 : '\xb0'
cp850 : '\xf8'
mac-roman : '\xa1'

jmf

Unfortunately, we’re using Boost.Python for wrapping C++ code, which makes it very difficult to use Unicode internally. (I actually like Boost.Python, but it does add significant baggage as far as designing a graphical app is concerned.) We’re using std::string on the C++ side, and the unicode strings will not be automatically converted - when I first tried to use a unicode build, everything broke almost immediately. I would need to wrap all of the wxPython controls with unicode-to-str conversion to be able to use the unicode build; this will probably be necessary at some point, but it’s about a week’s work to get it right.

-Nat

···

On Wed, Aug 17, 2011 at 7:44 AM, jmfauth wxjmfauth@gmail.com wrote:

The problem is not on the wx-builds side. The real problem

is most probably, you are not working in a unicode mode

on the Python level. The GUI only plays a secondary role.