minify _generated.cpp

This commit is contained in:
blueloveTH 2024-05-10 17:33:21 +08:00
parent 707a880c2e
commit 41e84e52a2
2 changed files with 23 additions and 22 deletions

View File

@ -8,15 +8,16 @@ def get_sources():
key = file.split(".")[0]
const_char_array = []
with open("python/" + file) as f:
# convert to char array (signed)
specials = { 10: '\\n', 34: '\\"' }
for c in f.read().encode('utf-8'):
if c < 128:
const_char_array.append(str(c))
if c in specials:
const_char_array.append(specials[c])
elif c >= 32 and c <= 126 and c != 92:
const_char_array.append(chr(c))
else:
const_char_array.append(str(c - 256))
const_char_array.append('0')
const_char_array = ','.join(const_char_array)
sources[key] = '{' + const_char_array + '}'
const_char_array.append(f'\\x{c:02x}')
const_char_array = ''.join(const_char_array)
sources[key] = '"' + const_char_array + '"'
return sources
sources = get_sources()

File diff suppressed because one or more lines are too long