Swiftpack.co - Package - safx/Emoji-Swift

Emoji-Swift

TravisCI codecov.io Platform License Version Carthage Swift Package Manager

String extension converting to and from emoji character and Emoji Cheat Sheet string.

Example Usage

import Emoji

":heart_eyes: :heart: :beer:".emojiUnescapedString
"🐢🐱🐷".emojiEscapedString

Methods

extension String {
    var emojiEscapedString: String
    var emojiUnescapedString: String
    static var emojis : [Emoji]
}

public struct Emoji {
    public init(shortname: String, codepoints: [String])
}

Custom Emoji

You can add own custom emoji to String.emojis.

If you use custom emojis, you should use only alpha-numeric characters for shortname of emojis to avoid any converting problem since this library internally uses RegExp to convert emojis.

// Add Custom Emoji
String.emojis.append(Emoji(shortname: "amp", codepoints: ["&\u{20dd}"]))

// Using Custom Emoji
":amp:".emojiUnescapedString
"&⃝".emojiEscapedString

Install

CocoaPods

pod 'Emoji-swift'

Swift Package Manager

Create a Package.swift file:

import PackageDescription

let package = Package(
    name: "Emoji",
    dependencies: [
        .Package(url: "https://github.com/safx/Emoji-Swift.git", majorVersion: 0)
    ]
)

And then, type swift build.

Manual Install

Just copy Emoji.swift and String+Emoji.swift into your project.

Github

link
Stars: 81
Help us keep the lights on

Dependencies

Used By

Total: 0