mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
Merge branch 'fix-data-to-c-line-endings' into 'master'
data-to-c.py: autodetect line endings Closes #2340 See merge request GNOME/glib!1974
This commit is contained in:
commit
bdea78295c
@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage: {0} <filename> <variable> <output>")
|
||||
|
||||
with open(sys.argv[1], "rb") as f:
|
||||
in_data = f.read().decode("utf-8", "backslashreplace")
|
||||
with open(sys.argv[1], "r", encoding="utf-8", errors="backslashreplace") as f:
|
||||
in_data = f.read()
|
||||
|
||||
b = [r"\x{:02x}".format(ord(c)) for c in in_data]
|
||||
|
||||
out_data = 'const char {0}[] = "'.format(sys.argv[2])
|
||||
|
Loading…
Reference in New Issue
Block a user