Add Emoji support from emoji-data.txt.

This commit is contained in:
Reece H. Dunn
2017-05-13 21:18:54 +01:00
parent f00587a94d
commit f93b98a69d
7 changed files with 206 additions and 23 deletions
+10 -2
View File
@@ -22,16 +22,23 @@ import sys
import ucd
ucd_rootdir = sys.argv[1]
emoji_rootdir = 'data/emoji'
csur_rootdir = 'data/csur'
null = ucd.CodePoint('0000')
properties = [
(ucd_rootdir, 'PropList'),
(ucd_rootdir, 'DerivedCoreProperties'),
(emoji_rootdir, 'emoji-data')
]
unicode_chars = {}
for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'):
for codepoint in data['CodePoint']:
unicode_chars[codepoint] = data
for propfile in ['PropList', 'DerivedCoreProperties']:
for data in ucd.parse_ucd_data(ucd_rootdir, propfile):
for propdir, propfile in properties:
for data in ucd.parse_ucd_data(propdir, propfile):
for codepoint in data['Range']:
try:
unicode_chars[codepoint][data['Property']] = 1
@@ -154,6 +161,7 @@ def properties(data):
props += (2 ** 30) * data.get('Pattern_White_Space', 0)
props += (2 ** 31) * data.get('Pattern_Syntax', 0)
props += (2 ** 32) * data.get('Prepended_Concatenation_Mark', 0)
props += (2 ** 33) * data.get('Emoji', 0) # emoji-data
return props
if __name__ == '__main__':
+4
View File
@@ -105,6 +105,10 @@ def strlist(x):
data_items = {
# Unicode Character Data:
'emoji-data': [
('Range', codepoint),
('Property', string)
],
'Blocks': [
('Range', codepoint),
('Name', string)