Created
October 28, 2019 16:44
-
-
Save GlinZachariah/7eef36a3385e7245d22caf3061bab81d to your computer and use it in GitHub Desktop.
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
import unicodedata | |
from unidecode import unidecode | |
def deEmojify(inputString): | |
returnString = "" | |
for character in inputString: | |
try: | |
character.encode("ascii") | |
returnString += character | |
except UnicodeEncodeError: | |
replaced = unidecode(str(character)) | |
if replaced != '': | |
returnString += replaced | |
else: | |
try: | |
returnString += unicodedata.name(character) | |
except ValueError: | |
returnString += "x" | |
return returnString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment