Created
September 14, 2015 04:06
-
-
Save nickwanhere/17f6a800960955e7b40e to your computer and use it in GitHub Desktop.
Remove emoji
This file contains 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
function toUnicode(theString) { | |
var unicodeString = ''; | |
for (var i=0; i < theString.length; i++) { | |
var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase(); | |
while (theUnicode.length < 4) { | |
theUnicode = '0' + theUnicode; | |
} | |
theUnicode = '\\u' + theUnicode; | |
unicodeString += theUnicode; | |
} | |
return unicodeString; | |
} | |
function removeEmoji(input) | |
{ | |
var temp = toUnicode(input); | |
temp = temp.replace(/\\uD83D\\u.{4}/g,''); | |
var r = /\\u([\d\w]{4})/gi; | |
temp = temp.replace(r, function (match, grp) { | |
return String.fromCharCode(parseInt(grp, 16)); } ); | |
temp = unescape(temp); | |
return temp; | |
} | |
var input = 'ASdasd 🙉🚓🚗🚍 好好'; | |
console.log(input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment