Code Monkey home page Code Monkey logo

smile's Introduction

Smile

❤️ Support my apps ❤️

❤️❤️😇😍🤘❤️❤️

Emoji in Swift. For reference, go to https://github.com/onmyway133/emoji

CI Status Version Carthage Compatible License Platform Swift

Features

  • Support emoji sequences
  • Handle skin tones, marks, genders, variation selectors
  • Support new iOS emojis

List

List all emojis

Smile.list()
emojiList
emojiCategories

Emoji

Check if a character is emoji

Smile.isEmoji(character: "🎉") // true

Check if a string contains any emoji

Smile.containsEmoji(string: "🎈 and 🎁") // true

Count number of emoji characters in a string

Smile.countEmoji("🎈 and 🎁") // 2

Count number of non-emoji characters in a string

Smile.countNonEmoji("🎈 and 🎁") // 5

Check if a string contains only a single emoji

Smile.isSingleEmoji("🎈 and 🎁") // false
Smile.isSingleEmoji("👨‍") // true
Smile.isSingleEmoji("👩🏽‍🧑‍") // false
Smile.isSingleEmoji("just plain text") // false

Check if a string contains only emojis

Smile.isEmojiOnly("🎈 and 🎁") // false
Smile.isEmojiOnly("👨‍") // true
Smile.isEmojiOnly("👩🏽‍🧑‍") // true
Smile.isEmojiOnly("just plain text") // false

Get emoji from unicode values

XCTAssertEqual(Smile.emoji(unicodeValues: [0x1F47B]), "👻")
XCTAssertEqual(Smile.emoji(unicodeValues: [0x0001F468, 0x200D, 0x2708]), "👨‍✈")

Unmodify an emoji

Smile.unmodify(emoji: "👨🏿") // 👨

Name

Show standard name of an emoji

Smile.name(emoji: "🇳🇴") // ["REGIONAL INDICATOR SYMBOL LETTER N", "REGIONAL INDICATOR SYMBOL LETTER O"])

Search emoji by keywords

Smile.emojis(keywords: ["GRINNING"]) // 😁, 😸

Flag

Search emoji flag by country code

Smile.emoji(countryCode: "no") // 🇳🇴

Alias

Search emoji by alias

Emoji data is from https://github.com/github/gemoji/blob/master/db/emoji.json

Smile.emoji(alias: "japanese_castle") // 🏯

Find alias by emoji

Smile.alias(emoji: "🏯") // japanese_castle

Replace alias within a string

Smile.replaceAlias(string: ":santa: is coming to :european_castle:") // 🎅 is coming to 🏰

Category

Find category of emoji

Emoji data is from https://github.com/github/gemoji/blob/master/db/Category-Emoji.json

Smile.category(emoji: "😁") // people

Manipulation

Extract all emojis within a string

Smile.extractEmojis(string: "Find 🔑and🔎") // 🔑🔎

Remove all emojis within a string

Smile.removeEmojis(string: "Find 🔑and🔎") // Find and

Assemble

Smile.assemble(emojis: ["👨", "🏫") // 👨‍🏫
Smile.assemble(emojis: ["👨", "👩", "👧", "👦"] // 👨‍👩‍👧‍👦

Disassemble

Smile.disassemble(emoji: "👨‍🏫") // [👨, 🏫]

Script

Update emoji list by running

node parser.js

Installation

Smile is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Smile'

Smile is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/Smile"

Author

Khoa Pham, [email protected]

Contributing

We would love you to contribute to Smile, check the CONTRIBUTING file for more info.

License

Smile is available under the MIT license. See the LICENSE file for more info.

smile's People

Contributors

dstranz avatar francescu avatar justinkumpe avatar kiliankoe avatar onmyway133 avatar vinayjn avatar xcuyao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

smile's Issues

Smile.unmodify handles ZWJ sequences in potentially unexpected ways

Consider 👩🏻‍❤️‍💋‍👨🏼, which is formed of

  • 👩 (woman)
  • Light Skin Tone
  • ZERO WIDTH JOINER
  • HEAVY BLACK HEART
  • VARIATION SELECTOR-16
  • ZERO WIDTH JOINER
  • 💋 (kiss mark)
  • ZERO WIDTH JOINER
  • 👨 (man)
  • Medium-light Skin Tone

If I do

Smile.unmodify(emoji: "👩🏻‍❤️‍💋‍👨🏼")

Everything except the 👩 is removed. This completely changes the meaning of the emoji, which I don't think unmodify is supposed to do. I had expected 👩‍❤️‍💋‍👨 instead. Is this intentional?

Package.swift

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Smile",
platforms: [
.macOS(.v10_15),
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Smile",
targets: ["Smile"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Smile",
dependencies: [],
path: "./Sources/"),
.testTarget(
name: "SmileTests",
dependencies: ["Smile"],
path: "./SmileTests/"),
]
)

Some emoji is missing

For example: ⏰⌛️💳🆙...

I suggest to update switch:

switch value {
        case 0x1F600...0x1F64F,
             0x1F300...0x1F5FF,
             0x1F680...0x1F6FF,
             0x1F1E6...0x1F1FF,
             0x2600...0x26FF,
             0x2700...0x27BF,
             0xFE00...0xFE0F,
             0x1F900...0x1F9FF,
             65024...65039,
             8400...8447,
             9100...9300,
             127000...127600:
            return true
        default:
            return false
        }

Demo support new Xcode

We need to upgrade demo Swift version, because new Xcode does not support the lower Swift version.

$ cd Example/SmileDemo/
$ pod install
Analyzing dependencies
Fetching podspec for `Smile` from `../../`
Downloading dependencies
Installing Smile (1.3.1)
[!] Unable to determine Swift version for the following pods:

- `Smile` does not specify a Swift version and none of the targets (`SmileDemo`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

This repository should be made obsolete

Since there is no active development on this repository since Nov 2018 (that's when 2.0.0 came out as a Pod) and no newer versions are released, I believe it is your duty to make it clear in the README.md that this repository is not actively maintained and people should steer clear of it. We have this repository as a dependency and now we have to do a lot of work to get rid of it. Thank you.

isEmojiOnly not working

I did the pod install and I am getting

import Smile

Smile.isEmojiOnly(message.value)

Module 'Smile' has no member 'isEmojiOnly'

Man Juggling 🤹‍♂ from categories does not match emoji as man_juggling

There is a strange behavior where the man_juggling from the emojiCategories isn't recognized as an emoji using isEmoji and doesn't any values in the emojiList when I do a CTRL-F in Xcode, even though it's very clearly there in the emojiList if I look visually.

I'm not sure exactly what's wrong or how far it extends to other emoji, but it definitely seems like something isn't right.

Build taking too long

The pod is taking too long to build after upgrading to Swift 5. From the output below it takes about 20 minutes and this is just the best case. It takes longer than that sometimes.

[23:33:54]: ▸ Processing Smile-Info.plist
[23:33:54]: ▸ Copying Smile-umbrella.h
[23:53:05]: ▸ Compiling Smile_vers.c
[23:53:05]: ▸ Compiling Smile-dummy.m
[23:53:06]: ▸ Compiling Smile_vers.c
[23:53:06]: ▸ Compiling Smile-dummy.m
[23:53:06]: ▸ Linking Smile
[23:53:06]: ▸ Linking Smile
[23:53:06]: ▸ Generating 'Smile.framework.dSYM'
[23:53:06]: ▸ Touching Smile.framework

How to apply skin tone modifier?

It seems like just appending a skin tone modifier from Smile.Sequence.SkinTone does not work for all emojis, so how do I know when to do this?

Add 🤩to categories

Some emoji are in the Emoji.swift but missing from the categories, for example, 🤩(starstruck)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.