source: proto/charsetcompiler/UCD/UnicodeNameData.py @ 4948

Last change on this file since 4948 was 4948, checked in by cameron, 3 years ago

Generator for UnicodeNameData?.cpp

File size: 968 bytes
Line 
1#
2# UnicodeNameData.py
3#
4# Robert D. Cameron
5# March 2, 2016
6#
7# Licensed under Open Software License 3.0.
8#
9#
10import re, string, os.path, cformat
11from UCD_parser import *
12
13UCD_dir = "8.0.0"
14
15UnicodeNameData_cpp_template = r"""
16#include "UnicodeNameData.h"
17const int Unamesize = %s;
18char Unamedata[Unamesize] = "%s";
19
20char * getUnicodeNameDataPtr() {
21  return Unamedata;
22}
23int getUnicodeNameDataSize() {
24  return Unamesize-1;
25}
26"""
27
28
29def genUnicodeNameData():
30    parsed_data = parse_UnicodeData_txt()
31    name_data_string = ""
32    name_data_len = 0
33    for record in parsed_data:
34        (cp, name, gc, ccc, bidic, decomp, decval, digitval, numval, bidim, uc, lc, tc) = record
35        name_data_string += cp + ";" + name + "\\n"
36        name_data_len += len(cp) + len(name) + 2
37    f = open('UnicodeNameData.cpp', 'w')
38    f.write(UnicodeNameData_cpp_template % (name_data_len + 1, name_data_string))
39    f.close()
40
41if __name__ == "__main__":
42  genUnicodeNameData()
Note: See TracBrowser for help on using the repository browser.