1

I am working in an application in which i need to look up emoji characters from the string means a string contains one or more emojis ? As i am new in swift so i am not aware about it.

exa. "Newbie " will returns yes and "Newbie" will returns no

jscs
  • 63,694
  • 13
  • 151
  • 195
Remedy
  • 11
  • 7

1 Answers1

2

Yes please use below method to identify emojies

public var checkcontainEmoji: Bool 
{
    for ucode in unicodeScalars
    {
        switch ucode.value
        {
        case 0x3030, 0x00AE, 0x00A9,
        0x1D000...0x1F77F,
        0x2100...0x27BF,
        0xFE00...0xFE0F,
        0x1F900...0x1F9FF:
            return true
        default:
            continue
        }
    }
    return false
}

Output : - "HI ".checkcontainEmoji --> TRUE

iDeveloper
  • 607
  • 5
  • 25