Skip to content

Instantly share code, notes, and snippets.

@eneko
Created July 23, 2019 23:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eneko/3e395e37865f1891e8315e6a26794f67 to your computer and use it in GitHub Desktop.
Save eneko/3e395e37865f1891e8315e6a26794f67 to your computer and use it in GitHub Desktop.
Determine if a Character is an emoji, in Swift
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))!)
}
}
@eneko
Copy link
Author

eneko commented Jul 23, 2019

Found this code online a long time ago, not sure where, probably Stack Overflow :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment