Trying to use the degree symbol

I have come into a problem when trying to use the degree symbol with tags. I have seen that the decimal representation for degree sign is 176. But when I use unichr(176), Instead of getting the actual degree symbol, I get this weird looking A in front of the degree symbol as shown, °. Is there a way to just get the degree sign itself?

Hold down ALT and press 248 on the numeric keypad, then release ALT. That will put in the degree symbol.

SOB…I knew there had to be easier way just never bothered to Google it.

Bookmarked and printed!

Here’s a single-sheet cheat sheet. (Say that one quickly…)

Yes, very useful. The best is when I write e-mails with all kinds of weird symbols and people always ask me how I do it. haha.

Steps to reproduce issue in script playground:

print unicode("°") print unichr(176) print ord("°")

…the first two print ° and the third errors with: “TypeError: ord() expected a character, but string of length 2 found”

Actually not seeing that, Sean. What locale are you using?

EDIT: Should say I’m seeing the last example you posted but not the others.

EDITED EDIT: Scratch that. I can see this on my 7.6.6 install running under Windows, but not My 7.7 install running under Linux.

FINAL EDIT to the EDITED EDIT that I edited before (anyone else getting lost?): Let me throw 7.6 on another Linux VM and see what we get. Stay tuned!

Previous post was running 7.6.6 on Win7-64

I just tested with 7.7 on Win7-64 and get the same result as you, Jordan - unichr and unicode examples both work in script playground, but ord still fails.

However, I still get the incorrect text when used in the actual project. We have three character value tags (int) coming from a controller - we use a project script to convert to characters for display in various tables and text fields. The text in all of these components is still “°”, despite a print in the project script properly showing just “°”.

Has anyone tried it in html?


Attached is a quickie window to illustrate. Script is in the Numeric Entry component.
Degrees Label_2014-08-08_0945.proj (5.01 KB)

SeanT, can you post a SSCCE project showing this problem, or give me some exact steps to replicate? I’d like to get it corrected if I can.

Just for the record, the way to print/display any string outside of 7-bit ASCII (ie with a character code > 127) is

print u'°'It’s stupid, but that’s the Python spec, and we made some changes in 7.6.4 to hold to the spec better (to support non-English languages). It doesn’t hurt to put the u in front of every string, even if it only contains 7-bit ASCII. Python doesn’t have consistent support for the unicode() construct, so I would advise going with u’somestring’ instead.

I have written a script
data.append([“Floating”, “Higher make Floating”, “PV4”, ‘°C’])
data.append([“Measure”, “T° Measure”, “PV5”, ‘°F’])
data.append([“Setpoint”, “T° Setpoint”, “ED2”, ‘°F’])
so here how do i filter the isssue of ° symbol because i cant write print u’ ° ’ as have 15 line of code with ° symbol.

data =
data.append(["Floating", "Higher make Floating", "PV4", u'°C'])
data.append(["Measure", u"T° Measure", "PV5", u'°F'])
data.append(["Setpoint", u"T° Setpoint", "ED2", u'°F'])

for x in data:
  for y in x:
    if u'°' in y:
      print y

// Output:

T° Measure
T° Setpoint

Just tried using u'°' and it didn't work in my scenario. I'm currently using 8.1.36 and am trying to get the degree symobol to show properly in a flex repeater. It shows up correctly in a normal flex view on a label text but gets ° when being repeated.

I've had to use the HTML code for my use cases (&#176), or you could try using &#8457 for °F

@ryan.white Can you use html in a script transform or an exprssion binding for perspective? Could you provide an exmaple of how? I tried within the text label and the binding to get it to show to no avail.

If you're going to use HTML then use HTML entities which are easy to remember.

&deg; : °
&pm; : ±
&Omega;: Ω
&omega;: ω.
&mu;: μ.
&ge; : ≥.
&le; : ≤.
&times; : ×. (It's different to 'x', so it's a technical expert indicator.)
There are hundreds and hundreds ...

You may also be able to use, for example, <sup>8</sup>, 8, and <sub>5</sub>, 5.

If I create a view with just a label and bind its text to an input parameter, then use it in a flex repeater populated with this:

def transform(self, value, quality, timestamp):
	return [
		{'val': '°'},
		{'val': u'°'},

I get this:

Maybe you can try passing unicode to your repeated view ?


Thank you, that did the trick.