/StringEmoji

๐Ÿ‘จโ€๐Ÿ’ป A swift 4.0 String extension class to handle Emoji related tasks.

Primary LanguageSwiftMIT LicenseMIT

StringEmoji

A swift 4.0 String extension class to handle Emoji related tasks.

CocoaPods installation

pod 'StringEmoji', :git => 'https://github.com/piterwilson/StringEmoji.git'

Usage

import StringEmoji

Documentation

Constants

let emojiCharacterSet: CharacterSet

Character set containing all known emoji (as described in official Unicode List 5.0 http://unicode.org/emoji/charts-5.0/emoji-list.html)

String

var isEmoji: Bool { get }

Whether or not the String instance represents a known single Emoji character

print("".isEmoji) // false
print("๐Ÿ˜".isEmoji) // true
print("๐Ÿ˜๐Ÿ˜œ".isEmoji) // false (String is not a single Emoji)

var containsEmoji: Bool { get }

Whether or not the String instance contains a known Emoji character

print("".containsEmoji) // false
print("๐Ÿ˜".containsEmoji) // true
print("๐Ÿ˜๐Ÿ˜œ".containsEmoji) // true

var unicodeName: String { get }

Applies a kCFStringTransformToUnicodeName - CFStringTransform on a copy of the String

print("รก".unicodeName) // \N{LATIN SMALL LETTER A WITH ACUTE}
print("๐Ÿ˜œ".unicodeName) // \N{FACE WITH STUCK-OUT TONGUE AND WINKING EYE}

var niceUnicodeName: String { get }

Returns the result of a kCFStringTransformToUnicodeName - CFStringTransform with \N{ prefixes and } suffixes removed

print("รก".unicodeName) // LATIN SMALL LETTER A WITH ACUTE}
print("๐Ÿ˜œ".unicodeName) // FACE WITH STUCK-OUT TONGUE AND WINKING EYE

Character

var isEmoji: Bool { get }

Whether or not the Character instance represents a known Emoji character

print("".isEmoji) // false
print("๐Ÿ˜".isEmoji) // true