Created
May 7, 2017 04:00
-
-
Save neet/8dca77d2aaaba13b5fc3999bdff4c1ae to your computer and use it in GitHub Desktop.
This file contains 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
#tester.py | |
import json | |
def splitStr(str, num): | |
s = '' | |
j = 0 | |
l = [] | |
for i in str: | |
s += i | |
j += 1 | |
if j == num: | |
l.append(s) | |
j = 0 | |
s = '' | |
if s: | |
l.append(s) | |
return l | |
f = open('/desktop/replaced_emoji.json','r+') | |
emoji_dict = json.loads(f.read()) | |
f2 = open('/desktop/replace_emoji.json','r+') | |
emoji_dict2 = json.loads(f2.read()) | |
for key, value in emoji_dict2.items(): | |
if value[0]=='1' and value[1]=='f': | |
# 5 | |
v = splitStr(value, 5) | |
strs = "" | |
for i in v: | |
print(v, i) | |
sr = chr(int(i.replace("1f", r"0x0001f",1), 16)) | |
strs += sr | |
ans = strs | |
else: | |
# 4 | |
v = splitStr(value, 4) | |
intr = 0 | |
for i in v: | |
intr += int("0x"+i, 16) | |
ans = chr(intr) | |
emoji_dict[key] = ans | |
json.dump(emoji_dict, f, ensure_ascii=False) |
This file contains 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 json | |
f = open('/desktop/eac.json','r+') | |
emojis = json.loads(f.read()) | |
f2 = open('/desktop/replace_emoji.json','r+') | |
emoji_dict = json.loads(f2.read()) | |
for key, value in emojis.items(): | |
emoji_dict[value["alpha code"]] = key | |
if value["aliases"] is not "": | |
if value["aliases"] in "|": | |
for i in value["aliases"].split("|"): | |
emoji_dict[i] = key | |
else: | |
emoji_dict[value["aliases"]] = key | |
# | |
# | |
# | |
json.dump(emoji_dict, f2, ensure_ascii=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment