I am working on an app that uses emojis on screen. These emojis are displayed on buttons that can be pressed by the users.
To make this app compatible with "accessibility requirements", a.k.a. voice over, etc. I need to get all the emojis' description text, and when user is using "voice over", the emojis can be read to the user.
For example, when user is choosing an emoji is a "smiley face", voice over should read "smiley face" to the user. However, I cannot label manually for each of the emoji, because there are thousands of them.
I am wondering where should I get all the emoji description texts?
Thanks!!
As you've noticed already, the Accessibility subsystem already knows how to accessibly describe an emoji if given one as part of an accessibility-oriented text (like the accessibilityLabel
for a control).
However, should you ever need emoji descriptions for other purposes (perhaps some kind of accessibility accommodation that doesn't go through the OS's Accessibility system), it might help to know how to find them yourself.
You can do this with Swift String
.applyingTransform
or ObjC NSString
.stringByApplyingTransform:
. (Both of these are wrappers for CoreFoundation's CFStringTransform
API, which is better documented and featured in an old NSHipster post.) Use the toUnicodeName
transform to get the names for emoji and other special characters — for example, as noted in the docs, that transforms “🐶🐮” into “{DOG FACE}{COW FACE}”.
(As you might notice in the StringTransform
docs and the aforelinked NSHipster article, there are lots of other fun things you can do with string transforms, too, like latinizing text from other scripts or producing the XML/HTML hex escape codes for unusual characters.)