2019-01-07 22:49:20 +00:00
|
|
|
import csv
|
|
|
|
|
|
|
|
def confusables():
|
2020-12-02 14:22:26 +00:00
|
|
|
with open('confusables.txt', encoding='utf-8-sig') as f:
|
|
|
|
# Filter comments
|
|
|
|
f = map(lambda line: line.split('#')[0], f)
|
|
|
|
return list(csv.DictReader(f, fieldnames=['Value', 'Target', 'Category'], delimiter=';'))
|
2019-01-07 22:49:20 +00:00
|
|
|
|
|
|
|
UNICODEDATA_FIELDS = (
|
2020-12-02 14:22:26 +00:00
|
|
|
"Value",
|
|
|
|
"Name",
|
|
|
|
"General_Category",
|
|
|
|
"Canonical_Combining_Class",
|
|
|
|
"Bidi_Class",
|
|
|
|
"Decomposition_Type",
|
|
|
|
"Decomposition_Mapping",
|
|
|
|
"Numeric_Type",
|
|
|
|
"Numeric_Mapping",
|
|
|
|
"Bidi_Mirrored",
|
|
|
|
"Unicode_1_Name",
|
|
|
|
"ISO_Comment",
|
|
|
|
"Simple_Uppercase_Mapping",
|
|
|
|
"Simple_Lowercase_Mapping",
|
|
|
|
"Simple_Titlecase_Mapping",
|
2019-01-07 22:49:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def data():
|
2022-06-12 11:15:02 +00:00
|
|
|
with open('UnicodeData.txt', encoding='utf-8') as f:
|
2020-12-02 14:22:26 +00:00
|
|
|
return list(csv.DictReader(f, fieldnames=UNICODEDATA_FIELDS, delimiter=';'))
|
2019-01-07 22:49:20 +00:00
|
|
|
|
|
|
|
def unhex(s):
|
2020-12-02 14:22:26 +00:00
|
|
|
return int(s, 16)
|
2019-01-07 22:49:20 +00:00
|
|
|
|
|
|
|
def unhex_sequence(s):
|
2020-12-02 14:22:26 +00:00
|
|
|
return [unhex(x) for x in s.split()] if '<' not in s else None
|