63

I would like to display a unicode character (the speaker symbol U+1F50A) in label. Is it possible to enter this symbol in Interface Builder?

ragnarius
  • 5,642
  • 10
  • 47
  • 68
  • 2
    In addition to technical issues in entering the symbol, consider how widely it can be expected to work. According to http://www.fileformat.info/info/unicode/char/1f50a/fontsupport.htm the only font that supports it is Symbola. There might be some other fonts, specific to iPhone for example, that support it. But the character is very new, introduced in Unicode 6.0. – Jukka K. Korpela Jun 17 '12 at 09:59
  • +1 Yes, the system font only has a bitmap of a speaker... – ragnarius Jun 17 '12 at 10:43

5 Answers5

108

Yes, you can click "Edit" > "Special Characters…" — there you can find all unicode characters (including the emoji) and copy/paste them where you set the label text in Interface Builder.

EDIT: In Xcode 6 it's "Edit" > "Emoji & Characters"

Xcode 7+: "Edit" > "Emoji & Symbols"

shim
  • 9,289
  • 12
  • 69
  • 108
graver
  • 15,183
  • 4
  • 46
  • 62
  • Yes, it works if I search for "speaker". But the symbol seams to be a bitmap and not a true font... – ragnarius Jun 17 '12 at 10:40
  • You can right-click on it and click `Copy Characted Info`, when you paste it you get the actual symbol (with some additional data)... – graver Jun 17 '12 at 10:47
  • 5
    it's now called **Edit > Emoji & Characters** in Xcode 6. – Raptor Apr 24 '15 at 03:47
  • 3
    And again, now it's called **Edit > Emoji & Symbols** in Xcode 7.3 – George Maisuradze Jul 19 '16 at 16:39
  • 3
    important to know if you're not used to typing literal unicode characters into the **Emoji & Characters** window: you type `0x` followed by the code, so if the unicode is `f19c`, you type `0xf19c` into the search bar, and if it's supported by default, the character will come up, otherwise an empty box character will come up -- that empty box character is your unicode character, double click to insert – shoe Jul 11 '17 at 19:52
  • Let me tell you all that apple is rejecting apps for emoji. @graver : Please put a workaround also what else can we do to make it to push successfully. – Abhishek Thapliyal Jan 25 '18 at 10:15
  • @AbhishekThapliyal what is the reason for rejection? – graver Jan 25 '18 at 10:16
  • If we are using emoji directly then apple is rejecting our app, so we putted hardcoded string in order to push it successfully. :( – Abhishek Thapliyal Jan 25 '18 at 10:18
  • Note that this menu option is not specific to Xcode. It is a system feature that you will find in the Edit menu of any application using the standard menus, plus the keyboard shortcut works in most applications. – shim Dec 26 '18 at 05:21
21

For those who tried doing it programmatically, but failed, just use this:

label.text = @"\U0001F50A";
JohnVanDijk
  • 3,546
  • 1
  • 24
  • 27
  • 2
    please make sure to use lower u and not upper U i.e. @"\u0001F50A" – vir us Apr 16 '16 at 18:12
  • No. Stick to upper U. When I tried this in Xcode 8.3 it spat out compiler error "Universal character name refers to a control character". I've test upper U and can confirm it works great. – Seoras May 10 '17 at 02:25
17

Do it programmatically.

Declare an IBOutlet for the Label, with the means of NSString type:

// UTF-8 Hexadecimal Encoding
NSString *myString = [NSString stringWithUTF8String:"0xF09F948A"];

myLabel.text = myString;

Also, take a look at this question.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Phillip
  • 4,276
  • 7
  • 42
  • 74
  • 1
    +1, but it does not work for the specific symbol. According to http://www.fileformat.info/info/unicode/char/1f50a/index.htm I should enter the string "\uD83D\uDD0A". But Xcode says the symbol is invalid – ragnarius Jun 17 '12 at 10:38
  • Uhm, then try to use a string and assign it to the label. I'll edit my post – Phillip Jun 17 '12 at 10:40
  • 1
    Sorry, now the label becomes 0xF09F948A . – ragnarius Jun 17 '12 at 11:10
  • Right. Well then i suggest to use a small UIImageView with the speaker, if you can put it. – Phillip Jun 17 '12 at 11:18
14

In Xcode 8/Swift 3 the easiest is to use the unicode escape:

let a = "\u{1F50A}"  
leinadsey
  • 161
  • 1
  • 5
9

It's fun why few people knew this. You can enter Unicode-symbols directly by holding "Option" and entering hex digit. All you need: (Sierra example) goto "Preference -> Keyboards -> Input Sources" and search for "Unicode Hex". It should appears under "Others" section. Next add it and then you be able enter Unicode-char anywhere just selecting this input source.

For example: ✓ = (Alt+2713), € - (20ac), etc. Most interesting section from 2100 to 2800. Full list you can found here - Unicode table

P.S.: This method sutable only for four-digit Unicodes

sVd
  • 1,043
  • 12
  • 12
  • 2
    One thing to point out. The option key trick only works while you have the Unicode Hex input source selected. – Scott Marchant Aug 07 '17 at 11:53
  • 1
    If you're using IcoMoon.ttf fonts inside your project (to embed icons) that's the more comfortable answer I've found, specially when you have to type particular unicode entrypoints defined in your icomoon set. Even though in the IB right panel textfield a [?] symbol will appear, inside the IB "XIB zone" the actual character will actually appear. – Isaac Aug 21 '18 at 11:52