Skip to content

Instantly share code, notes, and snippets.

@GlinZachariah
Created October 28, 2019 16:44
Show Gist options
  • Save GlinZachariah/7eef36a3385e7245d22caf3061bab81d to your computer and use it in GitHub Desktop.
Save GlinZachariah/7eef36a3385e7245d22caf3061bab81d to your computer and use it in GitHub Desktop.
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