7 out_fn=os.path.splitext(in_fn)[0]+".table"
10 for line in file(in_fn):
14 parts=line.split(None, 3)
16 code2=((code&0xFF)-0x21)+(((code>>8)&0xFF)-0x21)*94
17 data.append((code, eval(parts[2]), code2))
20 out.write("namespace {\n\n")
22 out.write("const unsigned short jisx0208_to_ucs_table[94*94] =\n{\n\t")
24 for code in xrange(94*94):
27 if (code%94%12)==0 or (code%94)==0:
29 if i<len(data) and data[i][2]==code:
30 out.write("0x%04X"%data[i][1])
36 data.sort(lambda x,y: cmp(x[1],y[1]))
37 out.write("struct UcsToJis\n{\n\tunsigned short ucs;\n\tunsigned short jis;\n};\nconst UcsToJis ucs_to_jisx0208_table[] =\n{\n\t")
38 for i in xrange(len(data)):
43 out.write("{ 0x%04X, 0x%04X }"%(data[i][1], data[i][0]))
46 out.write("unsigned ucs_to_jisx0208_table_size=%d;\n\n"%len(data))