fix(script): add ending for raw loader of ThorVG (#7186)

Co-authored-by: SamNofee <sam@nofee.fun>
This commit is contained in:
Link
2024-11-15 16:22:36 +08:00
committed by GitHub
parent 1eb2d3aee8
commit bfc47f424a
3 changed files with 15 additions and 4 deletions

View File

@@ -1,11 +1,18 @@
#!/usr/bin/env python3
import sys
import textwrap
import re
with open(sys.argv[1], 'r') as file:
s = file.read()
b = bytearray()
if '--filter-character' in sys.argv:
s = re.sub(r'[^\x00-\xff]', '', s)
if '--null-terminate' in sys.argv:
s += '\x00'
b.extend(map(ord, s))
for a in b: print(hex(a), end =", ")
print(textwrap.fill(', '.join([hex(a) for a in b]), 96))