Created
December 15, 2012 04:37
-
-
Save mwunsch/4291353 to your computer and use it in GitHub Desktop.
Explorations with emoji replacement in the browser: http://jsfiddle.net/a4JmQ/
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
| /*! | |
| * From: (c) 2012 Steven Levithan <http://slevithan.com/> | |
| * MIT License | |
| */ | |
| if (!String.fromCodePoint) { | |
| /*! | |
| * ES6 Unicode Shims 0.1 | |
| * (c) 2012 Steven Levithan <http://slevithan.com/> | |
| * MIT License | |
| */ | |
| String.fromCodePoint = function fromCodePoint () { | |
| var chars = [], point, offset, units, i; | |
| for (i = 0; i < arguments.length; ++i) { | |
| point = arguments[i]; | |
| offset = point - 0x10000; | |
| units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point]; | |
| chars.push(String.fromCharCode.apply(null, units)); | |
| } | |
| return chars.join(""); | |
| } | |
| } | |
| var $body = $(document.body), | |
| text = $body.html(), | |
| emojiHex = "1f449", | |
| emojiDescription = "<i>white right pointing backhand index</i>", | |
| emojiCodepoint = parseInt(emojiHex, 16), | |
| emojiRegex = new RegExp(String.fromCodePoint(emojiCodepoint), "g"); | |
| $body.html( text.replace(emojiRegex, emojiDescription) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment