28 lines
762 B
Python
28 lines
762 B
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import emoji_data_python as ed
|
|
|
|
emoji_cp = {emoji.unified: emoji for emoji in ed.emoji_data}
|
|
|
|
def main():
|
|
pass
|
|
|
|
def replace_emoji(line):
|
|
for e in list(set(ed.get_emoji_regex().findall(line))):
|
|
hexcp = format(ord(e),'x').upper()
|
|
em = emoji_cp[hexcp]
|
|
if em.text != None:
|
|
#print("Found smiley: " + em.text)
|
|
line=line.replace(e, em.text)
|
|
elif em.short_name != None:
|
|
#print("Found name: " + em.short_name)
|
|
line=line.replace(e, ":" + em.short_name + ":")
|
|
else:
|
|
line=line.replace(e, "?")
|
|
#print(line,end='')
|
|
return line.strip()
|
|
|
|
if __name__ == "__main__":
|
|
for line in sys.stdin:
|
|
print(replace_emoji(line))
|
|
|