Initial commit.
This commit is contained in:
commit
a8ddc68a1d
2 changed files with 34 additions and 0 deletions
16
README.md
Normal file
16
README.md
Normal file
|
|
@ -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).
|
||||
18
conv.py
Normal file
18
conv.py
Normal file
|
|
@ -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='')
|
||||
Loading…
Add table
Add a link
Reference in a new issue