17
I've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis?
Well, that's your job today!
Input
A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please state what you do if you do something different from a regular string for taking input.
Output
Print or return a truthy value if the input string contains only emojis, and a falsey value if it contains any characters other than emojis.
Wait a sec... what's an emoji?
An emoji is a character that falls in these ranges:
0x1F600...0x1F64F // Emoticons
0x1F300...0x1F5FF // Misc Symbols and Pictographs
0x1F680...0x1F6FF // Transport and Map
0x2600...0x26FF // Misc symbols
0x2700...0x27BF // Dingbats
0xFE00...0xFE0F // Variation Selectors
(I think)
This is code-golf, so shortest code in bytes wins❕
Test cases
"Is it an emoji? " -> False
"code-golf" -> False
" " -> False
"I have no fancy emojis :(" -> False
"" -> True
"" -> True
For you poor souls who cannot see emojis, here is an image of the test cases.
2Perhaps include a version (maybe an image) for those who can't see emojis? ;-) – ETHproductions – 2016-12-07T00:10:11.580
@ETHproductions, do you suggest I link to a photo of the test cases or something else? – Daniel – 2016-12-07T00:12:07.483
Well, there are emojis spread throughout the whole question, but I guess the only really important ones are in the test cases, so an image of just the test cases will work. – ETHproductions – 2016-12-07T00:14:00.713
@ETHproductions, I added a link to a photo of the test cases – Daniel – 2016-12-07T00:22:47.437
Can input be a numeric array of Unicode code points? Also, what range of characters/numbers can the input contain? – Luis Mendo – 2016-12-07T00:24:55.947
@LuisMendo, I suppose you can take an array of Unicode code points. The range of characters is the range I have above in the question in addition to any printable ASCII character. – Daniel – 2016-12-07T00:33:30.307
I'm going to vote to re-open. I don't see a valid reason as to why this is unclear. If a string contains only emojis, it's a truthy. if not, it's a falsy. – tuskiomi – 2017-08-15T16:05:07.907
You forgot some emoji: vomiting emoji, combining bloodstain
– mbomb007 – 2017-08-15T16:44:19.777