@@ -391,9 +391,19 @@ def gen_composition_table(canon_comp, out):
391
391
def gen_decomposition_tables (canon_decomp , compat_decomp , cjk_compat_variants_decomp , out ):
392
392
tables = [(canon_decomp , 'canonical' ), (compat_decomp , 'compatibility' ), (cjk_compat_variants_decomp , 'cjk_compat_variants' )]
393
393
for table , name in tables :
394
- gen_mph_data (name + '_decomposed' , table , "(u32, &'static [char])" ,
395
- lambda k : "(0x{:x}, &[{}])" .format (k ,
396
- ", " .join ("'\\ u{%s}'" % hexify (c ) for c in table [k ])))
394
+ offsets = {}
395
+ offset = 0
396
+ out .write ("pub(crate) const %s_DECOMPOSED_CHARS: &[char] = &[\n " % name .upper ())
397
+ for k , v in table .items ():
398
+ offsets [k ] = offset
399
+ offset += len (v )
400
+ for c in v :
401
+ out .write (" '\\ u{%s}',\n " % hexify (c ))
402
+ # The largest offset must fit in a u16.
403
+ assert offset < 65536
404
+ out .write ("];\n " )
405
+ gen_mph_data (name + '_decomposed' , table , "(u32, (u16, u16))" ,
406
+ lambda k : "(0x{:x}, ({}, {}))" .format (k , offsets [k ], len (table [k ])))
397
407
398
408
def gen_qc_match (prop_table , out ):
399
409
out .write (" match c {\n " )
0 commit comments