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.

alt-codes.net/

Bookmarked and printed!

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

http://usefulshortcuts.com/downloads/ALT-Codes.pdf

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?

outputString='<html>'+value+'&#176'

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:

°C
T° Measure
°F
T° Setpoint
°F