• Stars
    star
    182
  • Rank 210,039 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Encode and decode emoji unicode characters into emoji-cheat-sheet form.

Rumoji

This is a tool to convert Emoji Unicode codepoints into the human-friendly codes used by http://www.emoji-cheat-sheet.com/ and back again.

Why would you want to do this? Read this blog post: http://mwunsch.tumblr.com/post/34721548842/we-need-to-talk-about-emoji

tl;dr

By doing this, you can ensure that users across devices can see the author’s intention. You can always show users an image, but you can’t show them a range of characters their system does not support.

This gem is primarily for handling emoji characters in user-generated content. Depending on your technical stack, these characters could end up being lost.

Usage

Rumoji.encode(str)
# Takes a String, transforms Emoji into cheat-sheet codes

Rumoji.encode(str) { |emoji| #your code here }
# Takes a String, transforms Emoji into whatever you want

Rumoji.decode(str)
# Does the reverse of encode

Rumoji.encode_io(read, write)
# For an IO pipe (a read stream, and a write stream), transform Emoji from the
# read end, and write the cheat-sheet codes on the write end.

Rumoji.decode_io(read, write)
# Same thing but in reverse!

Installation

gem install rumoji

Note that rumoji has only been tested in Rubies >= 1.9!!!

Some examples:

puts Rumoji.encode("Lack of cross-device emoji support makes me 😭")
#=> Lack of cross-device emoji support makes me :sob:

Rumoji.encode_io(StringIO.new("πŸ’©")).string
#=> ":poop:"

Here's a fun file:

Rumoji.decode_io($stdin, $stdout)

On the command line

echo "But Rumoji makes encoding issues a :joy:" | ruby ./funfile.rb
#=> But Rumoji makes encoding issues a πŸ˜‚

Emoji methods

.code

The symbol of the emoji surrounded with colons

Rumoji.encode("😭") {|emoji| emoji.code}
#=> ":sob:"

.symbol

The symbol of the emoji

Rumoji.encode("😭") {|emoji| emoji.code}
#=> "sob"

.multiple?

Returns true if the emoji is made up of multiple code points. E.g. πŸ‡ΊπŸ‡Έ

Rumoji.encode("πŸ‡ΊπŸ‡Έ") {|emoji| emoji.multiple?}
#=> true

.string

The raw emoji

Rumoji.encode("😭") {|emoji| emoji.string}
#=> "😭"

Implement the emoji codes from emoji-cheat-sheet.com using a tool like gemoji along with Rumoji, and you'll easily be able to transform user input with raw emoji unicode into images you can show to all users.

Having trouble discerning what's happening in this README? You might be on a device with NO emoji support! All the more reason to use Rumoji. Transcode the raw unicode into something users can understand across devices!

Thanks!

Copyright

Copyright (c) 2012 - 2016 Mark Wunsch. Licensed under the MIT License.

More Repositories

1

weary

A framework and DSL for building RESTful web service clients
Ruby
482
star
2

tumblr

Command line interface and Ruby client for the Tumblr API (v2)
Ruby
282
star
3

thimble

[No Longer Maintained] Tumblr theme development tool. Protects your fingers from tedious copy-pasting.
PHP
165
star
4

handlebars.scala

A Scala implementation of the Handlebars templating language (a superset of Mustache).
Scala
112
star
5

prism

A Ruby microformat parser and HTML toolkit powered by Nokogiri
Ruby
63
star
6

overscan

A live coding environment for live streaming video
Racket
36
star
7

osxsub

Use OS X Text Substitution Preferences in your *nix pipeline
Ruby
30
star
8

hive-city

The hives of Necromunda rise from the ash wastes like sheer mountain peaks.
Elm
22
star
9

redwood

Simple Ruby trees
Ruby
18
star
10

gilt

Ruby client for the Gilt public API (dev.gilt.com)
Ruby
17
star
11

jquery-renewal

Enter the Carousel. This is the time of renewal. Be strong and you will be renewed.
HTML
15
star
12

sonic-sketches

Studies in Overtone
Clojure
7
star
13

emacs.d

'(wut)
Emacs Lisp
4
star
14

sublime

Settings for Sublime Text 2
4
star
15

mwunsch.github.io

steg der wunsch
Ruby
3
star
16

congrefs

Congrefs puts the long S into your text, according to the typographic rules of the 18th century.
JavaScript
3
star
17

collegiate-bowl

Meet the flamboyant players of the East/West Collegiate Bowl.
Ruby
3
star
18

dotfiles

~
Vim Script
3
star
19

redeye

An experimental CoffeeScript implementation atop the Rubinius VM
Ruby
2
star
20

mechwarper

Powering up... Portals online!
Shell
1
star
21

twitcher

A tiny JavaScript library for consuming the Twitter Search API
JavaScript
1
star
22

tellmountain

Send a notification to a HipChat room from stdin
Shell
1
star