Created
January 29, 2011 04:12
-
-
Save hoffrocket/801525 to your computer and use it in GitHub Desktop.
query plugin to replace emoji utf-8 characters with the iPhone glyphs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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" />'; | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That would be great! :) That would certainly help me debug why it isn't working on my site.