Skip to content

Instantly share code, notes, and snippets.

@mwunsch
Created October 20, 2012 03:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwunsch/3921924 to your computer and use it in GitHub Desktop.
Save mwunsch/3921924 to your computer and use it in GitHub Desktop.
emoji unicode to emoji-cheat-sheet.com codes
#!/usr/bin/env ruby
EMOJI_NAME_TO_CODEPOINT = {
"1F604" => :smile,
"1F606" => :laughing,
"1F60A" => :blush,
"1F603" => :smiley,
"263A" => :relaxed,
"1F60F" => :smirk,
"1F60D" => :heart_eyes,
"1F618" => :kissing_heart,
"1F61A" => :kissing_face,
"1F633" => :flushed,
"1F625" => :relieved,
"1F60C" => :satisfied,
"1F601" => :grin,
"1F609" => :wink,
"1F61C" => :wink2,
"1F61D" => :tongue,
"1F612" => :unamused,
"1F605" => :sweat_smile,
"1F613" => :sweat,
"1F629" => :weary,
"1F614" => :pensive,
"1F61E" => :dissapointed,
"1F616" => :confounded,
"1F628" => :fearful,
"1F630" => :cold_sweat,
"1F623" => :persevere,
"1F622" => :cry,
"1F62D" => :sob,
"1F602" => :joy,
"1F632" => :astonished,
"1F631" => :scream,
"1F62B" => :tired_face,
"1F620" => :angry,
"1F621" => :rage,
"1F62A" => :sleepy,
"1F60B" => :yum,
"1F637" => :mask,
"1F60E" => :sunglasses,
"1F635" => :dizzy_face,
"1F47F" => :imp,
"1F608" => :smiling_imp,
"1F610" => :neutral_face,
"1F636" => :no_mouth,
"1F607" => :innocent,
"1F4A9" => :poop,
"1F44D" => :thumbsup,
"1F44E" => :thumbsdown,
"1F479" => :japanese_ogre
}
remapped_codepoints = $stdin.codepoints.flat_map do |codepoint|
emoji = EMOJI_NAME_TO_CODEPOINT[codepoint.to_s(16).upcase]
emoji ? ":#{emoji}:".codepoints.entries : codepoint
end
puts remapped_codepoints.pack("U*")
@mwunsch
Copy link
Author

mwunsch commented Oct 20, 2012

I like the emoji support on iOS and Mountain Lion, but I get disappointed when my carefully chosen iconography does not appear in Chrome and assorted apps. My thought is that an app might want to convert the obscure Emoji Unicode (warning: this is a big page) into the more friendly codes used by GitHub and friends from the Emoji Cheat Sheet.

This script reads unicode from STDIN and handles that code swap. It doesn't support all the emoji because, it turns out, there's a lot of them.

@mwunsch
Copy link
Author

mwunsch commented Oct 20, 2012

GitHub won't allow me to post raw Emoji in this form :-( but usage, you can imagine, looks like this:

mark:~ $ echo "this code is DOO_DOO_EMOJI." | Projects/rack-emoji/emoji.rb
this code is :poop:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment