Skip to content

Instantly share code, notes, and snippets.

@hoffrocket
Created January 29, 2011 04:12
Show Gist options
  • Save hoffrocket/801525 to your computer and use it in GitHub Desktop.
Save hoffrocket/801525 to your computer and use it in GitHub Desktop.
query plugin to replace emoji utf-8 characters with the iPhone glyphs.
/**
* jquery plugin to replace emoji utf-8 characters with the iPhone glyphs.
* code adapted from here: https://github.com/konstantinov/jQuery.emoji
*
* Get your glyphs here:
* wget http://pukupi.com/post/1964/ -O - | perl -ne '/(e\d{3}.png)/ && print "http://pukupi.com/media/emoji/$1\n"' | xargs wget
*
* someone (Apple?) probably has copyright on the glyphs, not sure about reuse rules.
*/
$.fn.emoji = function() {
return this.each(function(){
$(this).html(function(i, oldHtml){
return oldHtml.replace(/([\ue001-\ue537])/g, function(s, eChar){
return '<img src="/glyphs/' + eChar.charCodeAt(0).toString(16) + '.png" alt="emoji" />';
});
});
});
};
@mads-hartmann
Copy link

Hi,

This doesn't seem to work using Safari 5.0.5. Does this still work for you?

Cheers,
Mads

@hoffrocket
Copy link
Author

yea, i can email you full example if you want

@mads-hartmann
Copy link

That would be great! :) That would certainly help me debug why it isn't working on my site.

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