I know how to replace text in a string. But that's using keyboard (ASCII) characters. In Objective C, how do I indicate a degree symbol? Also, how do I get the ASCII code for a character?
views:
353answers:
3
+3
A:
The degree symbol is Option-Shift-8 => °
. I believe you can also do: @"\u00B0"
.
To get the ASCII code for a character, just get the character into a char
and cast the char
to an int
.
Dave DeLong
2010-03-17 05:04:20
Thanks, that was a superfast response. This also yields a degree symbol: @"\xC2\xB0" .
Scott Pendleton
2010-03-17 05:14:00
That should be shift-option-8. The symbol you gave is a somewhat similar but unrelated small superscript circle that isn't used in English.
Chuck
2010-03-17 05:53:22
@Chuck huh, I never knew about shift-opt-8. I believe that opt-0 is technically the male ordinal, but it looked close enough for me. :) Editing answer.
Dave DeLong
2010-03-17 17:02:04
Actually, how the "male ordinal" symbol looks depends on the font. On some systems, it looks a lot like a degree symbol. On others (such as the one I'm on now), it has a line underneath.
Chuck
2010-03-17 18:01:56
A:
Option shift 8 also gives a similar character. It's the one I always use and I'm not sure of the difference between the two, except the SO font option 0 has a line under it.
Option+Shift+8 = °
Option+0 = º
David Kanarek
2010-03-17 05:12:48
+1
A:
To find characters not on your keyboard, select "Special Characters…" on the Edit menu.
To find ASCII values, look on http://www.asciitable.com/
Jon Reid
2010-03-17 05:18:15
♭♭♭♭ here is the symbol for a flatted note in music. Would I need to use a specific font in order to get that symbol? And how would I know what escape sequence to use?
Scott Pendleton
2010-03-17 13:45:49
@Scott use the Special Characters palette to find the letter. The tooltip (hover your mouse over the char) has the "Unicode:" info, which is your escape sequence (prefixed by `\u`.
Dave DeLong
2010-03-17 17:04:39