Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert unicode to emoji

Tags:

swift

emoji

I'm looking for a way to represent an emoji 📄 in my code as unicode which is then displayed as an actual 'image' in output text. I'd like to use http://apps.timwhitlock.info/unicode/inspect/hex/1F4C4 to display the 'page facing up' in application, but I don't like the idea of having pictures in my code (though it is working fine) ;)

like image 843
pJes2 Avatar asked Sep 09 '14 13:09

pJes2


People also ask

Can you create Unicode emojis?

These days, an organization called the Unicode Consortium maintains the standard set of emoji used by apps and platforms, and now counts more than 2,700 characters in Version 11 of the set, with more on the way. But if you don't see the exact character you need in the current bunch, yes, you can create your own.

Is utf8 an emoji?

Emojis look like images, or icons, but they are not. They are letters (characters) from the UTF-8 (Unicode) character set. UTF-8 covers almost all of the characters and symbols in the world.

How do I convert Word to emoji?

To add emojis to your document, go to the Insert tab and select Emoji. Word for the web displays some smileys and people. To choose from the entire set of emojis, select More Emojis.

How do you enter Unicode emojis?

Press ctrl+shift+u to start the unicode input kitten, shown below. In Code mode, you enter a Unicode character by typing in the hex code for the character and pressing Enter . For example, type in 2716 and press Enter to get ✖ .


1 Answers

You can use arbitrary Unicode characters directly in your source code

let string = "📄"

or use the Swift Unicode escape sequence:

let string = "\u{1F4C4}"

More information in the section about "String Literals" in the Swift reference.

like image 189
Martin R Avatar answered Sep 19 '22 15:09

Martin R