Created
July 23, 2019 23:56
-
-
Save eneko/3e395e37865f1891e8315e6a26794f67 to your computer and use it in GitHub Desktop.
Determine if a Character is an emoji, in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Character { | |
var isEmoji: Bool { | |
return Character(UnicodeScalar(UInt32(0x1d000))!) <= self && self <= Character(UnicodeScalar(UInt32(0x1f77f))!) | |
|| Character(UnicodeScalar(UInt32(0x2100))!) <= self && self <= Character(UnicodeScalar(UInt32(0x26ff))!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this code online a long time ago, not sure where, probably Stack Overflow :D