Member-only story

Working With Emoji in Swift

Emoji aren’t just simple strings

Alisa "Foxicorn" Nekrasova
Better Programming

Photo by Gaby Prestes Nekrasova on Instagram.

Emoji have become a big part of our life. iPhones and iPads have a special emoji keyboard (unless it’s turned off). We see them on websites, in mobile and desktop apps, and we enter them when writing texts and filling in forms.

How do we control them? How do we prevent users from entering emoji in UITextField? How do we parse emoji in the JSON response from a server? Let’s discuss it all.

A Little Bit of Theory

Emoji are a part of modern Unicode. Computers work with bits and bytes — not with smiles and other small pictures. Letters, numbers, and special characters in a text are all encoded in one or more bytes each. The same goes for emoji. They’re just symbols.

There are three standard modifications of Unicode. All of them are constantly evolving, new symbols appear, new languages are included. So there are actually more than three versions, but for us developers, it’s important to know three different standards:

  1. UTF-8 (Unicode Transformation Format eight bits): Each symbol in this encoding is presented as one or more bytes. Simple latin characters, digits, and some other symbols take only one byte (eight bits). If the first bit is 0, we know that it’s a one-byte symbol. If it’s a Russian, Chinese…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (1)

What are your thoughts?

There are three standard modifications of Unicode.

?

--