40 lines
1.1 KiB
Python
Executable File
40 lines
1.1 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import sys
|
|
|
|
header = sys.stdin.readline(), sys.stdin.readline()
|
|
dic = dict()
|
|
for line in sys.stdin:
|
|
if line[:1] != '0':
|
|
continue
|
|
|
|
fields = [x.strip() for x in line.split(';')]
|
|
u = int(fields[0], 16)
|
|
|
|
if u < 0x0600 or (u > 0x07FF and u != 0x200C and u != 0x200D):
|
|
raise Exception ("Ooops, unexpected unicode character: ", fields)
|
|
dic[u] = fields
|
|
|
|
print " /*"
|
|
print " * The following table is generated by running:"
|
|
print " *"
|
|
print " * ./gen-arabic-joining-table.py < ArabicShaping.txt"
|
|
print " *"
|
|
print " * on the ArabicShaping.txt file with the header:"
|
|
print " *"
|
|
for line in header:
|
|
print " * %s" % (line.strip())
|
|
print " */"
|
|
print " /* == Start of generated table == */"
|
|
for i in range(0x0600, 0x0800):
|
|
if i not in dic:
|
|
print " JOINING_TYPE_X, /* %04X */" % i
|
|
else:
|
|
entry = dic[i]
|
|
if entry[3] in ["ALAPH", "DALATH RISH"]:
|
|
value = "JOINING_GROUP_" + entry[3].replace(' ', '_')
|
|
else:
|
|
value = "JOINING_TYPE_" + entry[2]
|
|
print " %s, /* %s */" % (value, '; '.join(entry))
|
|
print " /* == End of generated table == */"
|