commit a8ddc68a1def2c651c97e5e60aee072e997143eb Author: Eirik Overby Date: Fri Aug 22 21:55:27 2025 +0200 Initial commit. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f887fcc --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +Tiny botched-together python script to replace (some) emoji with classic +smileys. I have never written python before, so forgive any transgressions. + +Takes text with unicode emojis on standard input, spits out emojis replaced by +either classic smileys (`:-)`) or textual variants (`:joy:`) on standard +output. + +Needs +``` +pip3.12 install emoji-data-python +``` +or whatever your platform wants. + +There are probably a million better ways to do this. + +(I'll be using this, at some point, in front of my Pleroma-Gopher interface). diff --git a/conv.py b/conv.py new file mode 100644 index 0000000..bb080de --- /dev/null +++ b/conv.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import sys +import emoji_data_python as ed +emoji_cp = {emoji.unified: emoji for emoji in ed.emoji_data} + +for line in sys.stdin: + 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='')