@@ -0,0 +1,1374 @@
+#!/usr/bin/python3%0A%0A# Input: https://www.unicode.org/Public/UNIDATA/Blocks.txt%0A%0Aimport io%0Aimport re%0A%0Aclass Builder(object):%0A    def __init__(self):%0A        pass%0A%0A    def read(self, infile):%0A        names = %5B%5D%0A        for line in infile:%0A            if line.startswith('#'):%0A                continue%0A            line = line.strip()%0A            if len(line) == 0:%0A                continue%0A            range, name = line.split(';', 2)%0A            start, end = range.split('..')%0A            name = name.lstrip()%0A%0A            names.append((start, end, name))%0A%0A        return names%0A%0A    def write(self, data):%0A        print('''%5C%0Astruct Block%0A%7B%0A  gunichar start;%0A  gunichar end;%0A  const char *name;%0A%7D;''')%0A        print('static const struct Block all_blocks%5B%5D =%5Cn  %7B')%0A        s = ''%0A        offset = 0%0A        for start, end, name in data:%0A            print('    %7B%7B 0x%7B0%7D, 0x%7B1%7D, %22%7B2%7D%22 %7D%7D,'.format(start, end, name))%0A        print('  %7D;')%0A%0Aif __name__ == '__main__':%0A    import argparse%0A%0A    parser = argparse.ArgumentParser(description='build')%0A    parser.add_argument('infile', type=argparse.FileType('r'),%0A                        help='input file')%0A    args = parser.parse_args()%0A%0A    builder = Builder()%0A    # FIXME: argparse.FileType(encoding=...) is available since Python 3.4%0A    data = builder.read(io.open(args.infile.name, encoding='utf_8_sig'))%0A    builder.write(data)%0A

Add a script for generating blocks