GithubHelp home page GithubHelp logo

exmoji's Introduction

Exmoji

Build Status Module Version Hex Docs Total Download License Last Updated

An Elixir/Erlang library providing low level operations for dealing with Emoji glyphs in the Unicode standard. ๐Ÿ†’

Exmoji is like a swiss-army knife for dealing with Emoji encoding issues. If all you need to do is translate :poop: into ๐Ÿ’ฉ, then there are plenty of other libs out there that will probably do what you want. But once you are dealing with Emoji as a fundamental part of your application, and you start to realize the nightmare of doublebyte encoding or variants, then this library may be your new best friend. ๐Ÿ™Œ

Exmoji is written by the same author as the Ruby emoji_data.rb gem, which is used in production by Emojitracker.com to parse well over 100M+ emoji glyphs daily. This version was written to provide all the same functionality while being even higher performance. ๐Ÿ’ซ

Installation

Add it to your deps list in your mix.exs:

defp deps do
  [
    {:exmoji, "~> 0.3.0"}
  ]
end

To get the development version, you can pull directly from GitHub:

defp deps do
  [
    {:exmoji, github: "mroth/exmoji"}
  ]
end

Modules

Full API documentation is available via standard module docs or here: https://mroth.github.io/exmoji/

Exmoji

The main library, with detailed search and conversion functions.

Some examples:

iex> Exmoji.from_unified "0023-20E3"
%Exmoji.EmojiChar{name: "HASH KEY", short_name: "hash", short_names: ["hash"],
 text: nil, unified: "0023-20E3", variations: ["0023-FE0F-20E3"]}

iex> Exmoji.all |> Enum.count
845

iex> Exmoji.all_with_variants |> Enum.count
107

iex> Exmoji.find_by_short_name("moon") |> Enum.count
13

iex> for t <- Exmoji.find_by_name("tree"), do: t.name
["EVERGREEN TREE", "DECIDUOUS TREE", "PALM TREE", "CHRISTMAS TREE",
"TANABATA TREE"]

Exmoji.EmojiChar

A struct representation of a single Emoji character and all of its associated metadata.

This module also contains some convenience methods for acting upon these structs. For example, EmojiChar.render/1 will produce a bitstring representation of an Emoji character suitable for transmission. It understands which Emoji have variant encodings and will do the right thing to make sure they are likely to display correctly on the other end.

iex> alias Exmoji.EmojiChar
nil

iex> for e <- Exmoji.all, EmojiChar.doublebyte?(e), do: e.short_name
["hash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
 "nine", "cn", "de", "es", "fr", "gb", "it", "jp", "kr", "ru", "us"]

iex> for m <- Exmoji.find_by_short_name("moon"), do: EmojiChar.render(m)
["๐ŸŒ‘", "๐ŸŒ’", "๐ŸŒ“", "๐ŸŒ”", "๐ŸŒ•", "๐ŸŒ–", "๐ŸŒ—", "๐ŸŒ˜", "๐ŸŒ™", "๐ŸŒš", "๐ŸŒ›", "๐ŸŒœ", "๐ŸŒ"]

Exmoji.Scanner

Provides very fast searches against binary strings for the presence of UTF-8 encoded Emoji glyphs. Whereas the Ruby and NodeJS versions of this library accomplish this via regular expressions, the Elixir version relies on optimized binary pattern matching, making it faster.

An example:

iex> for ec <- Exmoji.Scanner.scan("I โ™ฅ when marketers talk about the โ˜.") do
...>   IO.puts "Found some #{ec.short_name}!"
...> end
Found some hearts!
Found some cloud!
[:ok, :ok]

Contributing

Please be sure to run mix test and help keep test coverage at ๐Ÿ’ฏ. (Note: excoveralls is currently lying, actual test coverage is 100%, but it doesn't seem to catch dynamically defined functions. Do mix coveralls.details and manually verify those for now.)

There is a full benchmark suite available via mix bench. Please run before and after your changes to ensure you have not caused a performance regression.

Copyright and License

Copyright (c) 2014 Matthew Rothenberg

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

exmoji's People

Contributors

kianmeng avatar lowks avatar mroth avatar redrabbit avatar ukita 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

exmoji's Issues

Still maintained?

Hi, just wanted to do a quick check on if you are planning to continue to maintain this library, would be nice to look into some of the issues and PR's.

Emoji parser

Any plan for tokenize and detokenize emojis with skin tone support?

Which emoji version is supported?

I'm using this JS lib to add an emoji picker. https://github.com/joeattardi/emoji-button

I want you use this Elixir lib to validate the emoji being send is an emoji, and only a single emoji before inserting it into the DB, but even when I bump the emoji version down to 1.0, I notice that scanning the string turns up an empty list, even for a lot of popular emojis, e.g. zipper-mouth face/๐Ÿค. Is there plans to support the full 1.0 (or ideally later) set of emojis? Alternatively, is there another way to verify that a string contains a single emoji?

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.