Created
March 12, 2021 12:08
-
-
Save ewerybody/7c6bac0eeb3160daaad6d913e9ce040f to your computer and use it in GitHub Desktop.
find emojis under 100000/hex 186A0
This file contains hidden or 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
#py3 - find emojis under 100000/hex 186A0 | |
import os | |
MAX_NR = 100000 | |
URL = 'https://unicode.org/Public/emoji/13.1/emoji-test.txt' | |
TXT_NAME = 'emoji-test.txt' | |
TXT_PATH = os.path.abspath(os.path.join(__file__, '..', TXT_NAME)) | |
emojis = {} | |
content = '' | |
if os.path.isfile(TXT_PATH): | |
with open(TXT_PATH, encoding='utf8') as fob: | |
content = fob.read() | |
else: | |
import urllib.request | |
content = urllib.request.urlopen(URL).read().decode() | |
for line in content.split('\n'): | |
if line.startswith('#'): | |
continue | |
if not line.strip(): | |
continue | |
# get number blocks and description | |
nrs_str, line_end = line.split(';', 1) | |
nrs = nrs_str.strip().split() | |
# skip ones with multiple nr blocks | |
if len(nrs) > 1: | |
continue | |
# convert from hex | |
nr = int(nrs[0], 16) | |
if nr < MAX_NR: | |
emojis[nr] = line_end.rsplit('#')[1].strip() | |
for nr, txt in sorted(emojis.items()): | |
print('&#%i; : %s' % (nr, txt)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment